<template>
    <div class="project-request-container">
        <img
            v-if="this.version"
            :src="
                'https://img.shields.io/badge/version-' +
                this.version +
                '-success'
            "
            alt=""
        />
        <div class="form">
            <el-row>
                <el-alert
                    :title="errMessage"
                    type="error"
                    effect="dark"
                    v-if="errMessage"
                    :closable="false"
                >
                </el-alert>
            </el-row>
            <el-row class="choose" v-if="canEdit && errMessage == null">
                <el-col :xs="24" :sm="24" :lg="24">
                    <el-input
                        class="input-with-select"
                        style="max-width: 450px"
                        v-model="formLink"
                        v-if="mode === 'edit' || mode === 'view'"
                        id="inputFormLink"
                    >
                        <el-button
                            slot="append"
                            icon="el-icon-document-copy"
                            v-clipboard:copy="formLink"
                            v-clipboard:success="copyLinkSuccess"
                            title="复制查看链接"
                        ></el-button>
                    </el-input>
                    <span style="float: right">
                        <el-button
                            @click="submitForm('preservation')"
                            type="primary"
                            class="newReport"
                            >保存</el-button
                        >
                        <el-button
                            @click="formReset"
                            type="danger"
                            class="newReport"
                            v-if="mode === 'create'"
                            >重置</el-button
                        >
                        <el-button
                            @click="submitForm('submit')"
                            type="primary"
                            class="newReport"
                            >提交</el-button
                        >
                        <!-- <el-button
                            @click="submitForm('submit-force')"
                            type="primary"
                            class="newReport"
                            >强制提交</el-button
                        > -->
                        <el-button
                            @click="addEditor()"
                            type="primary"
                            class="newReport"
                            v-if="this.form.form_id !== null"
                            >添加协同编辑人</el-button
                        >
                    </span>
                </el-col>
            </el-row>
            <el-dialog
                title="请添加协同编辑人"
                :visible.sync="addEditorShow"
                width="36%"
                :before-close="handleClose"
            >
                <div v-if="lokAdd == false" style="padding: 10px 0">
                    <el-button type="primary" @click="lokAdd = true"
                        >添加</el-button
                    >
                </div>
                <div v-if="lokAdd == true" style="padding: 10px 0">
                    <el-autocomplete
                        style="width: 40%"
                        class="inline-input"
                        v-model="editorState"
                        :fetch-suggestions="querySearchAsync"
                        placeholder="请输入姓名或拼音"
                        :trigger-on-focus="false"
                        @select="EditorStateChange"
                    >
                        <template slot-scope="{ item }">
                            <div class="name" :id="'sale_' + item.id">
                                {{ item.value }}
                                {{ item.ldap }}
                            </div>
                        </template>
                    </el-autocomplete>
                    <el-button type="success" @click="lok()">确定</el-button>
                    <el-button type="warning" @click="lokAdd = false"
                        >取消</el-button
                    >
                </div>
                <el-tag
                    style="margin: 5px"
                    v-for="item in EditorValue"
                    :key="item.ldap"
                    closable
                    @close="EditorValueDel(item)"
                >
                    {{ item.name }}
                </el-tag>
            </el-dialog>
            <el-tabs
                v-show="errMessage == null"
                type="border-card"
                v-loading="loading"
                element-loading-text="正在提交至OA"
                element-loading-spinner="el-icon-loading"
                element-loading-background="rgba(0, 0, 0, 0.8)"
            >
                <el-tab-pane label="项目基础信息">
                    <el-form
                        :model="form"
                        :rules="baseRules"
                        ref="baseForm"
                        label-width="150px"
                    >
                        <el-row v-if="oldForm">
                            <el-col :span="8">
                                <el-form-item label="立项日期">
                                    <el-input
                                        v-model="form.created_at"
                                        :disabled="true"
                                    ></el-input>
                                </el-form-item>
                                <el-form-item label="项目周期">
                                    <el-input
                                        v-model="form.oldProjectPeriod"
                                        :disabled="true"
                                    ></el-input>
                                </el-form-item>
                            </el-col>
                            <el-col :span="8">
                                <el-form-item label="项目开始日期">
                                    <el-input
                                        v-model="form.init_project_start_date"
                                        :disabled="true"
                                    ></el-input>
                                </el-form-item>
                            </el-col>
                            <el-col :span="8">
                                <el-form-item label="项目结束日期">
                                    <el-input
                                        v-model="form.init_project_end_date"
                                        :disabled="true"
                                    ></el-input>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-divider></el-divider>
                        <el-row>
                            <el-col :span="8" style="margin-top: 60px">
                                <div>
                                    <el-form-item
                                        label="项目名称"
                                        prop="project_name"
                                    >
                                        <transition name="el-zoom-in-bottom">
                                            <div
                                                v-show="showName == true"
                                                class="transitions"
                                            >
                                                * 项目名称一经保存，不可修改
                                            </div>
                                        </transition>
                                        <transition name="el-zoom-in-bottom">
                                            <div
                                                v-if="mode === 'change'"
                                                class="transitions2"
                                            >
                                                *
                                                选择项目后状态即显示为变更待提交！！
                                            </div>
                                        </transition>
                                        <el-select
                                            v-if="mode === 'change'"
                                            v-model="form.project_name"
                                            :disabled="!canEditProjectName()"
                                            @change="handleProjectNameChanged"
                                            placeholder="请选择已立项项目"
                                        >
                                            <el-option
                                                v-for="project in archivedProjects"
                                                v-bind:key="project.name"
                                                :label="project.name"
                                                :value="project.id"
                                            ></el-option>
                                        </el-select>
                                        <el-input
                                            v-else
                                            v-model="form.project_name"
                                            :disabled="!canEditProjectName()"
                                            :prefix-icon="projectIcon"
                                            onkeyup="this.value = this.value.replace(/[^A-Za-z0-9_]/g,'');"
                                            @change="handleProjectNameChanged"
                                            @focus="showName = true"
                                            @blur="showName = false"
                                        ></el-input>
                                    </el-form-item>
                                    <el-form-item
                                        label="客户全称(原文)"
                                        prop="customer_full_name"
                                    >
                                        <el-autocomplete
                                            class="inline-input"
                                            v-model="form.customer_full_name"
                                            :fetch-suggestions="
                                                querySearchCustomer
                                            "
                                            placeholder="请输入客户全称或简称"
                                            @change="customer_full_name_value()"
                                            @select="handleSelectCustomer"
                                            @input="handleCustomerChanged"
                                            :trigger-on-focus="false"
                                            clearable
                                            :disabled="!canEdit"
                                        >
                                            <template slot-scope="{ item }">
                                                <div
                                                    class="name"
                                                    :id="'customer_' + item.id"
                                                >
                                                    {{ item.full_name }}
                                                </div>
                                            </template>
                                        </el-autocomplete>
                                        <div
                                            v-if="this.form.customer_id != ''"
                                            style="
                                                position: absolute;
                                                right: -70px;
                                                bottom: -8px;
                                            "
                                        >
                                            <el-tooltip
                                                placement="top-end"
                                                effect="light"
                                            >
                                                <div slot="content">
                                                    <el-table
                                                        :data="form.customerMsg"
                                                        style="width: 100%"
                                                    >
                                                        <el-table-column
                                                            label="合同条款要求"
                                                        >
                                                            <el-table-column
                                                                prop="clause_Small"
                                                                label="合同金额<50WRMB"
                                                                width="200"
                                                            >
                                                            </el-table-column>
                                                            <el-table-column
                                                                prop="clause_Large"
                                                                label="合同金额≥50WRMB"
                                                                width="200"
                                                            >
                                                            </el-table-column>
                                                        </el-table-column>
                                                        <el-table-column
                                                            prop="investment"
                                                            label="项目投入要求"
                                                            width="200"
                                                        >
                                                        </el-table-column>
                                                    </el-table>
                                                </div>
                                                <el-button type="text"
                                                    >查看<br />客户详情</el-button
                                                >
                                            </el-tooltip>
                                        </div>
                                    </el-form-item>
                                    <el-form-item
                                        label="公司全称(合同签署)"
                                        prop="corporation"
                                    >
                                        <el-autocomplete
                                            class="inline-input"
                                            v-model="form.corporation"
                                            :fetch-suggestions="
                                                querySearchCorporation
                                            "
                                            @change="corporation_value()"
                                            @select="handleSelectCorporation"
                                            placeholder="请输入公司全称或简称"
                                            clearable
                                            :trigger-on-focus="false"
                                            :disabled="!canEdit"
                                            @input="form.corporation_id = ''"
                                        >
                                            <template slot-scope="{ item }">
                                                <div
                                                    class="name"
                                                    :id="'corp_' + item.id"
                                                >
                                                    {{ item.name }}
                                                </div>
                                            </template>
                                        </el-autocomplete>
                                    </el-form-item>
                                    <el-form-item label="软件平台版本">
                                        <el-input
                                            placeholder="软件版本号"
                                            v-model="form.software_version"
                                            class="input-with-select"
                                            :disabled="!canEdit"
                                        >
                                            <el-select
                                                v-model="form.software_platform"
                                                placeholder="选择平台"
                                                slot="prepend"
                                                style="width: 105px"
                                                :disabled="!canEdit"
                                            >
                                                <el-option
                                                    :key="p.id"
                                                    v-for="p in software_platforms"
                                                    :label="p.name"
                                                    :value="p.id"
                                                ></el-option>
                                            </el-select>
                                        </el-input>
                                    </el-form-item>
                                    <el-form-item
                                        :label="
                                            oldForm
                                                ? '变更后项目周期'
                                                : '项目周期'
                                        "
                                    >
                                        <el-col>
                                            <el-input
                                                v-model="form.project_period"
                                                readonly
                                                :disabled="!canEdit"
                                            >
                                                <template slot="append"
                                                    >月
                                                </template>
                                            </el-input>
                                        </el-col>
                                    </el-form-item>
                                    <el-form-item
                                        label="项目总监"
                                        prop="project_director"
                                    >
                                        <el-autocomplete
                                            class="inline-input"
                                            v-model="form.project_director"
                                            placeholder="请输入姓名或拼音"
                                            :fetch-suggestions="
                                                querySearchAsync
                                            "
                                            @change="project_director_value()"
                                            @select="
                                                handleSelectProjectDirector
                                            "
                                            @input="
                                                form.project_director_id = ''
                                            "
                                            clearable
                                            :disabled="
                                                form.canEditProjectDirector ===
                                                    false || !canEdit
                                            "
                                            :trigger-on-focus="false"
                                        >
                                            <template slot-scope="{ item }">
                                                <div
                                                    class="name"
                                                    :id="'pd_' + item.id"
                                                >
                                                    {{ item.value }}
                                                    {{ item.ldap }}
                                                </div>
                                            </template>
                                        </el-autocomplete>
                                    </el-form-item>
                                    <el-form-item
                                        label="收入确认方式"
                                        prop="income_check_method"
                                    >
                                        <el-select
                                            v-model="form.income_check_method"
                                            placeholder="请选择"
                                            :disabled="!canEdit"
                                        >
                                            <el-option
                                                v-for="item in incomeCheckMethods"
                                                :key="item.value"
                                                :label="item.label"
                                                :value="item.value"
                                            ></el-option>
                                        </el-select>
                                    </el-form-item>
                                    <el-form-item
                                        label="项目级别"
                                        prop="project_level"
                                    >
                                        <el-select
                                            v-model="form.project_level"
                                            placeholder="请选择"
                                            :disabled="!canEdit"
                                        >
                                            <el-option
                                                v-for="item in form.project_level_list"
                                                :key="item"
                                                :label="item.label"
                                                :value="item.value"
                                            ></el-option>
                                        </el-select>
                                    </el-form-item>
                                    <el-form-item
                                        label="所属事业部"
                                        prop="business_department"
                                    >
                                        <el-autocomplete
                                            class="inline-input"
                                            v-model="form.business_department"
                                            :fetch-suggestions="
                                                querySearchDepartment
                                            "
                                            placeholder="请输入事业部名或拼音"
                                            @change="
                                                business_department_value()
                                            "
                                            @select="handleSelectDepartment"
                                            @input="handleDepartmentChanged"
                                            clearable
                                            :trigger-on-focus="false"
                                            :disabled="!canEdit"
                                        ></el-autocomplete>
                                    </el-form-item>
                                    <el-form-item label="所属事业群">
                                        <el-input
                                            v-model="form.business_group"
                                            readonly
                                            :disabled="!canEdit"
                                        ></el-input>
                                    </el-form-item>
                                    <el-form-item
                                        label="主交付/产品中心"
                                        v-if="form.business_group_id == '30'"
                                        prop="product"
                                    >
                                        <el-select
                                            v-model="form.product"
                                            placeholder="请选择"
                                            :disabled="!canEdit"
                                        >
                                            <el-option
                                                v-for="item in productList"
                                                :key="item.id"
                                                :label="item.name"
                                                :value="item.id"
                                            ></el-option>
                                        </el-select>
                                    </el-form-item>
                                    <el-form-item
                                        label="预研项目名称"
                                    >
                                        <el-autocomplete
                                            class="inline-input"
                                            v-model="form.pre_project_name"
                                            placeholder="请输入名称"
                                            :fetch-suggestions="pre_project_name_value"
                                            @select="handleSelectPreProjectName"
                                            :disabled="!canEdit"
                                            :trigger-on-focus="false"
                                            value-key="name"
                                        >
                                        </el-autocomplete>
                                    </el-form-item>
                                </div>
                            </el-col>
                            <el-col :span="8" style="margin-top: 60px">
                                <div>
                                    <el-form-item
                                        label="项目经理"
                                        prop="project_manager"
                                    >
                                        <el-input
                                            v-if="requestType === 1"
                                            class="inline-input"
                                            v-model="form.project_manager"
                                            :disabled="true"
                                        ></el-input>
                                        <el-autocomplete
                                            v-else
                                            class="inline-input"
                                            v-model="form.project_manager"
                                            placeholder="请输入姓名或拼音"
                                            :disabled="!canEdit"
                                            :fetch-suggestions="
                                                querySearchAsync
                                            "
                                            :trigger-on-focus="false"
                                            @change="project_manager_value"
                                            @select="
                                                handleSelectProjectManager
                                            "
                                            @input="
                                                form.project_manager_id = ''
                                            "
                                            clearable
                                        >
                                            <template slot-scope="{ item }">
                                                <div
                                                    class="name"
                                                    :id="'pd_' + item.id"
                                                >
                                                    {{ item.value }}
                                                    {{ item.ldap }}
                                                </div>
                                            </template>
                                        </el-autocomplete>
                                    </el-form-item>
                                    <el-form-item label="客户简称">
                                        <el-input
                                            v-model="form.customer_abrv_name"
                                            readonly
                                            :disabled="!canEdit"
                                        ></el-input>
                                    </el-form-item>
                                    <el-form-item
                                        label="业务类型"
                                        prop="business_type"
                                    >
                                        <el-cascader
                                            style="width: 100%"
                                            v-model="form.business_type"
                                            :options="businessOptions"
                                            @change="handleBusinessTypeChange"
                                            :disabled="!canEdit"
                                        >
                                        </el-cascader>
                                    </el-form-item>
                                    <el-form-item label="硬件平台版本">
                                        <el-input
                                            placeholder="硬件版本号"
                                            v-model="form.hardware_version"
                                            class="input-with-select"
                                            :disabled="!canEdit"
                                        >
                                            <el-select
                                                v-model="form.hardware_platform"
                                                placeholder="选择平台"
                                                slot="prepend"
                                                style="width: 105px"
                                                :disabled="!canEdit"
                                            >
                                                <el-option
                                                    :key="p.id"
                                                    v-for="p in hardware_platforms"
                                                    :label="p.name"
                                                    :value="p.id"
                                                ></el-option>
                                            </el-select>
                                        </el-input>
                                    </el-form-item>
                                    <el-form-item
                                        :label="
                                            oldForm
                                                ? '变更后项目开始日期'
                                                : '项目开始日期'
                                        "
                                        prop="project_start_date"
                                    >
                                        <el-col>
                                            <el-date-picker
                                                @change="projectStartDateChanged"
                                                type="date"
                                                placeholder="选择日期"
                                                value-format="yyyy-MM-dd"
                                                v-model="
                                                    form.project_start_date
                                                "
                                                style="width: 100%"
                                                :disabled="!canEdit"
                                                @focus="projectStartDateFocus(form.project_start_date)"
                                            ></el-date-picker>
                                        </el-col>
                                    </el-form-item>
                                    <el-form-item label="申请类型">
                                        <el-select
                                            v-model="form.application_type"
                                            placeholder="请选择"
                                            disabled
                                        >
                                            <el-option
                                                v-for="item in application_types"
                                                :key="item.value"
                                                :label="item.label"
                                                :value="item.value"
                                            >
                                            </el-option>
                                        </el-select>
                                    </el-form-item>
                                    <el-form-item
                                        label="预计合同签订日期"
                                        prop="est_contract_signing_date"
                                    >
                                        <el-col>
                                            <el-date-picker
                                                type="date"
                                                placeholder="选择日期"
                                                value-format="yyyy-MM-dd"
                                                v-model="
                                                    form.est_contract_signing_date
                                                "
                                                style="width: 100%"
                                                :disabled="!canEdit"
                                            ></el-date-picker>
                                        </el-col>
                                    </el-form-item>
                                    <el-form-item
                                        label="币种"
                                        prop="currency_id"
                                    >
                                        <el-select
                                            v-model="form.currency_id"
                                            @change="handleSelectCurrency"
                                            :disabled="!canEdit"
                                        >
                                            <el-option
                                                :key="p.currency_name"
                                                v-for="p in exchangeRate"
                                                :label="p.currency_name"
                                                :value="p.id"
                                            ></el-option>
                                        </el-select>
                                    </el-form-item>
                                    <el-form-item label="所属事业部负责人">
                                        <el-input
                                            v-model="
                                                form.business_department_manager
                                            "
                                            readonly
                                            :disabled="!canEdit"
                                        ></el-input>
                                    </el-form-item>
                                    <el-form-item label="所属事业群负责人">
                                        <el-input
                                            v-model="
                                                form.business_group_manager
                                            "
                                            readonly
                                            :disabled="!canEdit"
                                        ></el-input>
                                    </el-form-item>
                                    <el-form-item
                                        label="预研人月"
                                    >
                                        <el-input
                                            v-model="form.pre_man_month"
                                            placeholder="请输入数字"
                                            oninput="value=value.replace(/^0[0-9]|[^\d.]/g,'')"
                                            @input="
                                                    calculateTotalManMonth()
                                            "
                                            :disabled="!canEdit"
                                        ></el-input>
                                    </el-form-item>
                                </div>
                            </el-col>
                            <el-col :span="8">
                                <div>
                                    <el-form-item
                                        label="DEAL ID"
                                    >
                                        <el-input
                                            v-model="form.deal_id"
                                            placeholder="请输入该项目对应的HubSpot的DEAL ID(仅汽车BG填写)"
                                            :disabled="!canEdit"
                                        ></el-input>
                                    </el-form-item>
                                    <el-form-item
                                        v-if="requestType === 0"
                                        label="立项日期"
                                        prop="created_at"
                                    >
                                        <el-col>
                                            <el-date-picker
                                                type="date"
                                                placeholder="选择日期"
                                                value-format="yyyy-MM-dd"
                                                v-model="form.created_at"
                                                style="width: 100%"
                                                :disabled="!canEdit"
                                            ></el-date-picker>
                                        </el-col>
                                    </el-form-item>
                                    <el-form-item
                                        v-if="requestType === 1"
                                        label="变更日期"
                                        prop="changed_at"
                                    >
                                        <el-col>
                                            <el-date-picker
                                                type="date"
                                                placeholder="选择日期"
                                                value-format="yyyy-MM-dd"
                                                v-model="form.changed_at"
                                                style="width: 100%"
                                                :disabled="!canEdit"
                                            ></el-date-picker>
                                        </el-col>
                                    </el-form-item>
                                    <el-form-item label="公司总部所在区域">
                                        <el-col>
                                            <el-input
                                                v-model="form.customer_region"
                                                readonly
                                                :disabled="!canEdit"
                                            ></el-input>
                                        </el-col>
                                    </el-form-item>
                                    <el-form-item
                                        label="客户类别"
                                        v-show="false"
                                    >
                                        <el-col>
                                            <el-input
                                                v-model="form.customer_category"
                                                readonly
                                                :disabled="!canEdit"
                                            ></el-input>
                                        </el-col>
                                    </el-form-item>
                                    <el-form-item
                                        label="客户等级"
                                        v-show="false"
                                    >
                                        <el-col>
                                            <el-input
                                                :value="
                                                    displayCustomerLevel(
                                                        form.customer_level
                                                    )
                                                "
                                            ></el-input>
                                        </el-col>
                                    </el-form-item>
                                    <el-form-item label="销售人员" prop="sales">
                                        <el-autocomplete
                                            class="inline-input"
                                            v-model="form.sales"
                                            placeholder="请输入姓名或拼音"
                                            :fetch-suggestions="
                                                querySearchAsync
                                            "
                                            @change="sales_value()"
                                            @select="handleSelectSales"
                                            @input="form.sales_id = ''"
                                            clearable
                                            :disabled="
                                                form.canEditProjectDirector ===
                                                    false || !canEdit
                                            "
                                            :trigger-on-focus="false"
                                        >
                                            <template slot-scope="{ item }">
                                                <div
                                                    class="name"
                                                    :id="'sale_' + item.id"
                                                >
                                                    {{ item.value }}
                                                    {{ item.ldap }}
                                                </div>
                                            </template>
                                        </el-autocomplete>
                                    </el-form-item>
                                    <el-form-item label="是否整体转包">
                                        <el-checkbox
                                            v-model="form.entire_subcontract"
                                            :disabled="!canEdit"
                                        ></el-checkbox>
                                    </el-form-item>
                                    <el-form-item
                                        :label="
                                            oldForm
                                                ? '变更后项目结束日期'
                                                : '项目结束日期'
                                        "
                                        prop="project_end_date"
                                    >
                                        <el-col>
                                            <el-date-picker
                                                @change="projectEndDateChanged"
                                                type="date"
                                                placeholder="选择日期"
                                                value-format="yyyy-MM-dd"
                                                v-model="form.project_end_date"
                                                style="width: 100%"
                                                :disabled="!canEdit"
                                                @focus="projectEndDateFocus(form.project_end_date)"
                                            ></el-date-picker>
                                        </el-col>
                                    </el-form-item>
                                    <el-form-item
                                        label="产品类型"
                                        prop="product_category"
                                    >
                                        <el-cascader
                                            v-model="form.product_category"
                                            :options="productionOptions"
                                            :disabled="!canEdit"
                                        >
                                        </el-cascader>
                                    </el-form-item>
                                    <el-form-item label="是否预研项目">
                                        <el-checkbox
                                            v-model="form.is_pre_dev"
                                            :disabled="true"
                                        ></el-checkbox>
                                    </el-form-item>
                                    <el-form-item label="汇率">
                                        <el-input
                                            v-model="form.currency"
                                            readonly
                                            :disabled="!canEdit"
                                        ></el-input>
                                    </el-form-item>
                                    <el-form-item
                                        label="信息安全级别"
                                        prop="security_level"
                                    >
                                        <el-select
                                            v-model="form.security_level"
                                            :disabled="!canEdit"
                                        >
                                            <el-option
                                                v-for="item in form.security_level_list"
                                                :key="item"
                                                :label="item.label"
                                                :value="item.value"
                                            ></el-option>
                                        </el-select>
                                    </el-form-item>
                                    <el-form-item
                                        label="账期"
                                        prop="billing_period"
                                    >
                                        <el-input
                                            v-model="form.billing_period"
                                            oninput="value=value.replace(/^0[0-9]|[^\d.]/g,'')"
                                            :disabled="!canEdit"
                                        ></el-input>
                                    </el-form-item>
                                    <el-form-item
                                        label="预研成本（人民币）"
                                    >
                                        <el-input
                                            v-model="form.pre_cost"
                                            placeholder="请输入数字"
                                            oninput="value=value.replace(/^0[0-9]|[^\d.]/g,'')"
                                            @input="calculateTotalCost()"
                                            :disabled="!canEdit"
                                        ></el-input>
                                    </el-form-item>
                                </div>
                            </el-col>
                        </el-row>
                        <el-divider></el-divider>
                        <el-row>
                            <el-col :span="8">
                                <el-form-item label="预计市场规模≥2000万">
                                    <el-select
                                        v-model="
                                            form.est_market_size_over_20_million
                                        "
                                        placeholder="请选择"
                                        :disabled="!canEdit"
                                    >
                                        <el-option
                                            v-for="item in form.est_market_size_over_20_million_list"
                                            :key="item"
                                            :label="item.label"
                                            :value="item.value"
                                        ></el-option>
                                    </el-select>
                                </el-form-item>
                                <el-form-item label="是否新方向">
                                    <el-select
                                        v-model="form.is_new_direction"
                                        placeholder="请选择"
                                        :disabled="!canEdit"
                                    >
                                        <el-option
                                            label="是"
                                            value="0"
                                        ></el-option>
                                        <el-option
                                            label="否"
                                            value="1"
                                        ></el-option>
                                    </el-select>
                                </el-form-item>
                                <el-form-item
                                    prop="one_time_release_success_rate"
                                    label="软件一次发版成功率"
                                >
                                    <el-input
                                        placeholder=""
                                        v-model="
                                            form.one_time_release_success_rate
                                        "
                                        oninput="value=value.replace(/^0[0-9]|[^\d.]/g,'')"
                                        :disabled="!canEdit"
                                    >
                                        <template slot="append">%</template>
                                    </el-input>
                                </el-form-item>
                            </el-col>
                            <el-col :span="8">
                                <el-form-item label="是否新客户">
                                    <el-select
                                        v-model="form.is_new_customer"
                                        placeholder="请选择"
                                        :disabled="!canEdit"
                                    >
                                        <el-option
                                            label="是"
                                            value="0"
                                        ></el-option>
                                        <el-option
                                            label="否"
                                            value="1"
                                        ></el-option>
                                    </el-select>
                                </el-form-item>
                                <el-form-item
                                    prop="process_compliance"
                                    label="流程符合度"
                                >
                                    <el-input
                                        placeholder=""
                                        v-model="form.process_compliance"
                                        oninput="value=value.replace(/^0[0-9]|[^\d.]/g,'')"
                                        :disabled="!canEdit"
                                    >
                                        <template slot="append">%</template>
                                    </el-input>
                                </el-form-item>
                                <el-form-item
                                    label="硬件改版次数"
                                    prop="hardware_revision_count"
                                >
                                    <el-input
                                        placeholder="不涉及硬件发版时，请填0"
                                        v-model.number="
                                            form.hardware_revision_count
                                        "
                                        oninput="value=value.replace(/^0[0-9]|[^\d.]/g,'')"
                                        :disabled="!canEdit"
                                    >
                                    </el-input>
                                </el-form-item>
                            </el-col>
                            <el-col :span="8">
                                <el-form-item label="是否新市场">
                                    <el-select
                                        v-model="form.is_new_market"
                                        placeholder="请选择"
                                        :disabled="!canEdit"
                                    >
                                        <el-option
                                            label="是"
                                            value="0"
                                        ></el-option>
                                        <el-option
                                            label="否"
                                            value="1"
                                        ></el-option>
                                    </el-select>
                                </el-form-item>
                                <el-form-item
                                    class="table-form"
                                    prop="defect_density"
                                    label="全工程缺陷密度"
                                >
                                    <el-input
                                        placeholder=""
                                        v-model="form.defect_density"
                                        oninput="value=value.replace(/^0[0-9]|[^\d.]/g,'')"
                                        :disabled="!canEdit"
                                    >
                                        <template slot="append"
                                            >件/KL
                                        </template>
                                    </el-input>
                                </el-form-item>
                            </el-col>
                        </el-row>
                        <el-row>
                            <el-form-item
                                label="项目概要"
                                prop="project_summary"
                            >
                                <el-input
                                    type="textarea"
                                    v-model="form.project_summary"
                                    :disabled="!canEdit"
                                    maxlength="2000"
                                    show-word-limit
                                ></el-input>
                            </el-form-item>
                        </el-row>
                        <el-row>
                            <el-form-item
                                label="项目变更原因说明"
                                prop="project_change_reason"
                                v-if="oldCalculated"
                            >
                                <el-input
                                    type="textarea"
                                    v-model="form.project_change_reason"
                                    :disabled="!canEdit"
                                    maxlength="2000"
                                    show-word-limit
                                ></el-input>
                            </el-form-item>
                        </el-row>
                    </el-form>
                </el-tab-pane>
                <el-tab-pane label="工数预测">
                    <h3>公司员工</h3>
                    <div v-if="requestType === 1">
                        <h3>历史</h3>
                        <el-button
                            @click="outExc_oldDialog = true"
                            type="success"
                            plain
                            style="margin-bottom: 10px"
                        >
                            导出excel
                        </el-button>
                        <el-dialog title="" :visible.sync="outExc_oldDialog">
                            <el-table
                                id="outTab_old"
                                :data="form.historyManPowerInput"
                                border
                                style="width: 100%"
                            >
                                <el-table-column
                                    width="130"
                                    label=""
                                    prop="rowName"
                                >
                                </el-table-column>
                                <el-table-column
                                    :key="index"
                                    v-for="(p, index) in form.pastMonths"
                                    width="130"
                                    :label="p"
                                >
                                    <template slot-scope="scope">
                                        <span>{{
                                            scope.row.input[index]
                                        }}</span>
                                        <span v-if="scope.row.total">{{
                                            sumManMonthPerM(index, 0)
                                                | num45Filter
                                        }}</span>
                                    </template>
                                </el-table-column>
                            </el-table>
                            <div slot="footer" class="dialog-footer">
                                <el-button @click="outExc_oldDialog = false"
                                    >取 消</el-button
                                >
                                <el-button
                                    type="success"
                                    plain
                                    @click="outExc_old"
                                    >下 载</el-button
                                >
                            </div>
                        </el-dialog>
                        <div class="tip">
                            tip:双击任一周即可设定为项目起始周和结束周，可以批量填写工数
                        </div>
                        <el-form :model="form" ref="from">
                            <el-table
                                :cell-class-name="addClass_old"
                                :row-class-name="tableRowIndex"
                                @cell-dblclick="selectCell_old"
                                :data="form.historyManPowerInput"
                                border
                                style="width: 100%"
                            >
                                <el-table-column
                                    width="130"
                                    label=""
                                    prop="rowName"
                                >
                                </el-table-column>
                                <el-table-column
                                    :key="index"
                                    v-for="(p, index) in form.pastMonths"
                                    width="130"
                                    :label="p"
                                    :index="index"
                                    type="cell"
                                >
                                    <template slot-scope="scope">
                                        <el-form-item
                                            :prop="
                                                'historyManPowerInput[' +
                                                scope.$index +
                                                '].input[' +
                                                index +
                                                ']'
                                            "
                                            :rules="{
                                                required: true,
                                                message: '请输入数字,不能为空',
                                                trigger: ['blur', 'change'],
                                            }"
                                            style="margin-bottom: 0"
                                        >
                                            <el-input
                                                size="mini"
                                                :disabled="!canEdit"
                                                placeholder="请输入数字"
                                                v-model="scope.row.input[index]"
                                                oninput="value=value.replace(/^0[0-9]|[^\d.]/g,'')"
                                                @input="
                                                    calculateTotalManMonth()
                                                "
                                            >
                                            </el-input>
                                            <span v-if="scope.row.total">{{
                                                sumManMonthPerM(index, 0)
                                                    | num45Filter
                                            }}</span>
                                        </el-form-item>
                                    </template>
                                </el-table-column>
                            </el-table>
                        </el-form>
                    </div>
                    <h3>预测</h3>
                    <el-button
                        type="primary"
                        class="btn-add"
                        size="medium"
                        icon="el-icon-plus"
                        @click="addManPowerRow()"
                        v-if="canEdit"
                        :disabled="form.project_period ? false : true"
                        >增加
                    </el-button>
                    <el-button
                        @click="outExc_newDialog = true"
                        type="success"
                        plain
                    >
                        导出excel
                    </el-button>
                    <el-dialog title="" :visible.sync="outExc_newDialog">
                        <el-table
                            id="outTab_new"
                            :data="form.manPowerInput"
                            border
                            style="width: 100%"
                        >
                            <el-table-column
                                label="实施部门"
                                prop="implement_department"
                                width="250"
                            >
                            </el-table-column>
                            <el-table-column
                                label="人员类型"
                                prop="labour_type"
                                width="150"
                            >
                                <template slot-scope="scope">
                                    <span v-if="!scope.row.total"
                                        >公司员工</span
                                    >
                                </template>
                            </el-table-column>
                            <el-table-column
                                label="角色"
                                prop="role"
                                width="150"
                            >
                            </el-table-column>
                            <el-table-column
                                label="平均薪资系数"
                                prop="k"
                                width="120"
                            >
                            </el-table-column>
                            <el-table-column
                                label="工数(人月)"
                                prop="man_month"
                                width="100"
                            >
                                <template slot-scope="scope">
                                    <span v-if="!scope.row.total">{{
                                        sumManMonth(scope.row) | num45Filter
                                    }}</span>
                                    <span v-if="scope.row.total">{{
                                        sumTotalManMonth(form.manPowerInput)
                                            | num45Filter
                                    }}</span>
                                </template>
                            </el-table-column>
                            <el-table-column
                                :key="index"
                                v-for="(p, index) in form.nextMonths"
                                :label="p"
                                width="130"
                                :prop="p[index]"
                            >
                                <template slot-scope="scope">
                                    <span v-if="!scope.row.total">{{
                                        scope.row.input[index]
                                    }}</span>
                                    <span v-if="scope.row.total">{{
                                        sumManMonthPerM(index, 0) | num45Filter
                                    }}</span>
                                </template>
                            </el-table-column>
                        </el-table>
                        <div slot="footer" class="dialog-footer">
                            <el-button @click="outExc_newDialog = false"
                                >取 消</el-button
                            >
                            <el-button type="success" plain @click="outExc_new"
                                >下 载</el-button
                            >
                        </div>
                    </el-dialog>
                    <div class="tip">
                        tip:双击任一周即可设定为项目起始周和结束周，可以批量填写工数
                    </div>
                    <el-form :model="form" ref="from">
                        <el-table
                            :cell-class-name="addClass"
                            :row-class-name="tableRowIndex"
                            @cell-dblclick="selectCell"
                            :data="form.manPowerInput"
                            border
                            style="width: 100%"
                        >
                            <el-table-column width="80">
                                <template slot-scope="scope">
                                    <el-button
                                        v-if="!scope.row.total"
                                        icon="el-icon-delete"
                                        type="danger"
                                        :disabled="!canEdit"
                                        size="mini"
                                        @click="removeManPowerRow(scope.row)"
                                    ></el-button>
                                </template>
                            </el-table-column>
                            <el-table-column
                                :key="v.field"
                                v-for="v in form.manPowerColumns"
                                :prop="v.field"
                                :label="v.title"
                                :width="v.width"
                            >
                                <template slot-scope="scope">
                                    <span v-if="v.field === 'id'">{{
                                        scope.row.id
                                    }}</span>

                                    <el-autocomplete
                                        v-if="
                                            v.field == 'implement_department' &&
                                            !scope.row.total
                                        "
                                        class="inline-input"
                                        size="mini"
                                        :disabled="!canEdit"
                                        v-model="scope.row.implement_department"
                                        :fetch-suggestions="
                                            querySearchDepartment
                                        "
                                        placeholder="请输入事业部名或拼音"
                                        clearable
                                        @change="implement_department_company_value(scope.row)"
                                    ></el-autocomplete>
                                    <el-select
                                        v-if="
                                            v.field === 'labour_type' &&
                                            !scope.row.total
                                        "
                                        size="mini"
                                        v-model="scope.row[v.field]"
                                        placeholder="请选择"
                                        disabled
                                    >
                                        <el-option
                                            value="0"
                                            label="公司员工"
                                        ></el-option>
                                        <el-option
                                            value="1"
                                            label="外协人员"
                                        ></el-option>
                                    </el-select>
                                    <el-select
                                        v-if="
                                            v.field === 'role' &&
                                            !scope.row.total
                                        "
                                        size="mini"
                                        :disabled="!canEdit"
                                        v-model="scope.row[v.field]"
                                        @change="calculateTotalManMonth()"
                                        placeholder="请选择"
                                    >
                                        <el-option
                                            v-for="item in roles"
                                            :key="item.name_zh"
                                            :label="item.name_zh"
                                            :value="item.name_zh"
                                        >
                                        </el-option>
                                    </el-select>
                                    <el-input
                                        v-if="
                                            v.field === 'k' && !scope.row.total
                                        "
                                        size="mini"
                                        :disabled="!canEdit"
                                        placeholder=""
                                        v-model="scope.row[v.field]"
                                        @change="calculateTotalManMonth()"
                                        oninput="value=value.replace(/^0[0-9]|[^\d.]/g,'')"
                                    >
                                    </el-input>
                                    <span
                                        v-if="
                                            v.field === 'man_month' &&
                                            !scope.row.total
                                        "
                                        >{{
                                            sumManMonth(scope.row) | num45Filter
                                        }}</span
                                    >
                                    <span
                                        v-if="
                                            v.field === 'man_month' &&
                                            scope.row.total
                                        "
                                        >{{
                                            sumTotalManMonth(form.manPowerInput)
                                                | num45Filter
                                        }}</span
                                    >
                                </template>
                            </el-table-column>
                            <el-table-column
                                :key="index"
                                v-for="(p, index) in form.nextMonths"
                                :label="p"
                                width="130"
                                :prop="p[index]"
                                :index="index"
                                type="cell"
                            >
                                <template slot-scope="scope">
                                    <el-form-item
                                        :prop="
                                            'manPowerInput[' +
                                            scope.$index +
                                            '].input[' +
                                            index +
                                            ']'
                                        "
                                        :rules="{
                                            required: true,
                                            message: '请输入数字,不能为空',
                                            trigger: ['blur', 'change'],
                                        }"
                                        style="margin-bottom: 0"
                                    >
                                        <el-input
                                            v-if="!scope.row.total"
                                            size="mini"
                                            :disabled="!canEdit"
                                            placeholder="请输入数字"
                                            v-model="scope.row.input[index]"
                                            oninput="value=value.replace(/^0[0-9]|[^\d.]/g,'')"
                                            @input="calculateTotalManMonth()"
                                        >
                                        </el-input>
                                        <span v-if="scope.row.total">{{
                                            sumManMonthPerM(index, 0)
                                                | num45Filter
                                        }}</span>
                                    </el-form-item>
                                </template>
                            </el-table-column>
                        </el-table>
                    </el-form>
                    <el-divider></el-divider>
                    <!--外包人力-->
                    <h3>外协人员</h3>
                    <h3>预测</h3>
                    <el-button
                        type="primary"
                        class="btn-add"
                        size="medium"
                        icon="el-icon-plus"
                        @click="addOutSourcingManPowerRow()"
                        v-if="canEdit"
                        :disabled="!form.project_period"
                        >增加
                    </el-button>
                    <el-button
                        @click="outsourceExc_Dialog = true"
                        type="success"
                        plain
                    >
                        导出excel
                    </el-button>
                    <el-dialog title="" :visible.sync="outsourceExc_Dialog">
                        <el-table
                            id="outsourceTab"
                            :data="form.manPowerOutSourcingInput"
                            border
                            style="width: 100%"
                        >
                            <el-table-column
                                label="实施部门"
                                prop="implement_department"
                                width="250"
                            >
                            </el-table-column>
                            <el-table-column
                                label="人员类型"
                                prop="labour_type"
                                width="150"
                            >
                                <template slot-scope="scope">
                                    <span v-if="!scope.row.total"
                                        >外协人员</span
                                    >
                                </template>
                            </el-table-column>
                            <el-table-column
                                label="角色"
                                prop="role"
                                width="150"
                            >
                            </el-table-column>
                            <el-table-column
                                label="平均薪资"
                                prop="avg_salary"
                                width="120"
                            >
                            </el-table-column>
                            <el-table-column
                                label="工数(人月)"
                                prop="man_month"
                                width="100"
                            >
                                <template slot-scope="scope">
                                    <span v-if="!scope.row.total">{{
                                        sumManMonth(scope.row) | num45Filter
                                    }}</span>
                                    <span v-if="scope.row.total">{{
                                        sumTotalManMonth(
                                            form.manPowerOutSourcingInput
                                        ) | num45Filter
                                    }}</span>
                                </template>
                            </el-table-column>
                            <el-table-column
                                :key="index"
                                v-for="(p, index) in this.form.allMonths"
                                :label="p"
                                width="120"
                                :prop="p[index]"
                            >
                                <template slot-scope="scope">
                                    <span v-if="!scope.row.total">
                                        {{ scope.row.input[index] }}
                                    </span>
                                    <span v-else>{{
                                        sumManMonthPerM(index, 1) | num45Filter
                                    }}</span>
                                </template>
                            </el-table-column>
                        </el-table>
                        <div slot="footer" class="dialog-footer">
                            <el-button @click="outsourceExc_Dialog = false"
                                >取 消</el-button
                            >
                            <el-button
                                type="success"
                                plain
                                @click="outsourceExc"
                                >下 载</el-button
                            >
                        </div>
                    </el-dialog>
                    <div class="tip">
                        tip:双击任一周即可设定为项目起始周和结束周，可以批量填写工数
                    </div>
                    <el-form :model="form" ref="from">
                        <el-table
                            :cell-class-name="addClass_outside"
                            :row-class-name="tableRowIndex"
                            @cell-dblclick="selectCell_outside"
                            :data="form.manPowerOutSourcingInput"
                            border
                            style="width: 100%"
                        >
                            <el-table-column width="80">
                                <template slot-scope="scope">
                                    <span v-if="scope.row.total">{{
                                        scope.row.text
                                    }}</span>
                                    <el-button
                                        v-else
                                        icon="el-icon-delete"
                                        type="danger"
                                        size="mini"
                                        :disabled="!canEdit"
                                        @click="
                                            removePowerOutSourcingRow(scope.row)
                                        "
                                    ></el-button>
                                </template>
                            </el-table-column>
                            <el-table-column
                                :key="v.field"
                                v-for="v in form.manPowerOutSourcingColumns"
                                :prop="v.field"
                                :label="v.title"
                                :width="v.width"
                            >
                                <template slot-scope="scope">
                                    <span v-if="v.field == 'id'"></span>
                                    <el-autocomplete
                                        v-if="
                                            v.field == 'implement_department' &&
                                            !scope.row.total
                                        "
                                        class="inline-input"
                                        department
                                        :disabled="!canEdit"
                                        v-model="scope.row.implement_department"
                                        :fetch-suggestions="
                                            querySearchDepartment
                                        "
                                        placeholder="请输入事业部名"
                                        @select="handleDepartmentChanged"
                                        @change="implement_department_company_value(scope.row)"
                                        clearable
                                    ></el-autocomplete>
                                    <el-select
                                        v-if="
                                            v.field == 'labour_type' &&
                                            !scope.row.total
                                        "
                                        size="mini"
                                        v-model="scope.row[v.field]"
                                        disabled
                                        placeholder="请选择"
                                    >
                                        <el-option
                                            value="0"
                                            label="公司员工"
                                        ></el-option>
                                        <el-option
                                            value="1"
                                            label="外协人员"
                                        ></el-option>
                                    </el-select>
                                    <el-select
                                        v-if="
                                            v.field == 'role' &&
                                            !scope.row.total
                                        "
                                        size="mini"
                                        :disabled="!canEdit"
                                        v-model="scope.row[v.field]"
                                        placeholder="请选择"
                                    >
                                        <el-option
                                            v-for="item in roles"
                                            :key="item.name_zh"
                                            :label="item.name_zh"
                                            :value="item.name_zh"
                                        >
                                        </el-option>
                                    </el-select>
                                    <el-input
                                        v-if="
                                            v.field == 'avg_salary' &&
                                            !scope.row.total
                                        "
                                        size="mini"
                                        :disabled="!canEdit"
                                        placeholder=""
                                        v-model="scope.row[v.field]"
                                        @change="calculateTotalManMonth()"
                                        oninput="value=value.replace(/^0[0-9]|[^\d.]/g,'')"
                                    >
                                    </el-input>
                                    <span
                                        v-if="
                                            v.field == 'man_month' &&
                                            !scope.row.total
                                        "
                                        >{{
                                            sumManMonth(scope.row) | num45Filter
                                        }}</span
                                    >
                                    <span
                                        v-if="
                                            v.field == 'man_month' &&
                                            scope.row.total
                                        "
                                        >{{
                                            sumTotalManMonth(
                                                form.manPowerOutSourcingInput
                                            ) | num45Filter
                                        }}</span
                                    >
                                </template>
                            </el-table-column>
                            <el-table-column
                                :key="index"
                                v-for="(p, index) in this.form.allMonths"
                                :label="p"
                                width="120"
                                :prop="p[index]"
                                :index="index"
                                type="cell"
                            >
                                <template slot-scope="scope">
                                    <el-form-item
                                        :prop="
                                            'manPowerOutSourcingInput[' +
                                            scope.$index +
                                            '].input[' +
                                            index +
                                            ']'
                                        "
                                        :rules="{
                                            required: true,
                                            message: '请输入数字,不能为空',
                                            trigger: ['blur', 'change'],
                                        }"
                                        style="margin-bottom: 0"
                                    >
                                        <el-input
                                            v-if="!scope.row.total"
                                            size="mini"
                                            :disabled="!canEdit"
                                            placeholder="请输入数字"
                                            v-model="scope.row.input[index]"
                                            @input="calculateTotalManMonth()"
                                            oninput="value=value.replace(/^0[0-9]|[^\d.]/g,'')"
                                        >
                                        </el-input>
                                        <span v-else>{{
                                            sumManMonthPerM(index, 1)
                                                | num45Filter
                                        }}</span>
                                    </el-form-item>
                                </template>
                            </el-table-column>
                        </el-table>
                    </el-form>
                </el-tab-pane>
                <el-tab-pane label="财务预测">
                    <el-button
                        @click="financeTableExcDialog = true"
                        type="success"
                        plain
                    >
                        导出excel
                    </el-button>
                    <el-dialog title="" :visible.sync="financeTableExcDialog">
                        <el-tabs
                            id="financeTable"
                            tab-position="left"
                            :disabled="!canEdit"
                        >
                            <el-tab-pane label="项目收入">
                                <el-table
                                    :data="form.projectIncome"
                                    border
                                    show-summary
                                    :summary-method="getSummaries"
                                    style="width: 100%"
                                >
                                    <el-table-column
                                        label="项目收入-投入项"
                                        width="230"
                                    >
                                        <template slot-scope="scope">
                                            <span>{{ scope.row.title }}</span>
                                        </template>
                                    </el-table-column>
                                    <el-table-column
                                        label="标准(平均单价)"
                                        width="140"
                                    >
                                        <template slot-scope="scope">
                                            <span
                                                v-if="
                                                    scope.row.field ===
                                                    'nre_offer_per_unit'
                                                "
                                                >{{ scope.row.value }}</span
                                            >
                                            <span v-else>——</span>
                                        </template>
                                    </el-table-column>
                                    <el-table-column label="合计" width="100">
                                        <template slot-scope="scope">
                                            <span
                                                v-if="
                                                    scope.row.field !=
                                                    'nre_offer_per_unit'
                                                "
                                            >
                                                <span
                                                    v-if="
                                                        scope.row.field ==
                                                            'nre_income_rmb' ||
                                                        scope.row.field ==
                                                            'royalty_rmb' ||
                                                        scope.row.field ==
                                                            'training_rmb' ||
                                                        scope.row.field ==
                                                            'internal_outsourcing_rmb' ||
                                                        scope.row.field ==
                                                            'other_rmb'
                                                    "
                                                >
                                                    {{
                                                        (calculateSummary(
                                                            scope.row
                                                        ) *
                                                            form.currency)
                                                            | num45Filter
                                                    }}
                                                </span>
                                                <span v-else>
                                                    {{
                                                        calculateSummary(
                                                            scope.row
                                                        ) | num45Filter
                                                    }}
                                                </span>
                                            </span>
                                        </template>
                                    </el-table-column>
                                    <el-table-column
                                        :key="index"
                                        v-for="(p, index) in form.allMonths"
                                        :label="p"
                                        width="100"
                                    >
                                        <template slot-scope="scope">
                                            <span
                                                v-if="
                                                    scope.row.type ===
                                                        'input' &&
                                                    scope.row.field !=
                                                        'nre_offer_per_unit'
                                                "
                                                >{{
                                                    scope.row.input[index]
                                                }}</span
                                            >
                                            <span
                                                v-if="
                                                    scope.row.type === 'span' &&
                                                    scope.row.field !==
                                                        'nre_income'
                                                "
                                                >{{
                                                    (scope.row.input[index] *
                                                        form.currency)
                                                        | num45Filter
                                                }}</span
                                            >
                                            <span
                                                v-if="
                                                    scope.row.type === 'span' &&
                                                    scope.row.field ===
                                                        'nre_income'
                                                "
                                                >{{
                                                    scope.row.input[index]
                                                        | num45Filter
                                                }}</span
                                            >
                                        </template>
                                    </el-table-column>
                                </el-table>
                            </el-tab-pane>
                            <el-tab-pane label="采购成本/商品销售成本">
                                <el-table
                                    :data="form.purchaseCost"
                                    border
                                    show-summary
                                    :summary-method="getSummaries"
                                    style="width: 100%"
                                    :span-method="objectSpanMethod_purchaseCost"
                                >
                                    <el-table-column
                                        label="采购成本/商品销售成本-投入项"
                                        width="230"
                                    >
                                        <template slot-scope="scope">
                                            <span>{{ scope.row.title }}</span>
                                        </template>
                                    </el-table-column>
                                    <el-table-column
                                        label="标准(平均单价)"
                                        width="140"
                                    >
                                        <template>
                                            <span>——</span>
                                        </template>
                                    </el-table-column>
                                    <el-table-column label="合计" width="100">
                                        <template slot-scope="scope">
                                            <span>{{
                                                calculateSummary(scope.row)
                                                    | num45Filter
                                            }}</span>
                                        </template>
                                    </el-table-column>
                                    <el-table-column
                                        :key="index"
                                        v-for="(p, index) in form.allMonths"
                                        :label="p"
                                        width="100"
                                    >
                                        <template slot-scope="scope">
                                            <span
                                                v-if="
                                                    scope.row.type === 'input'
                                                "
                                                >{{
                                                    scope.row.input[index]
                                                }}</span
                                            >
                                            <span
                                                v-if="scope.row.type === 'span'"
                                                >{{
                                                    scope.row.input[index]
                                                        | num45Filter
                                                }}</span
                                            >
                                        </template>
                                    </el-table-column>
                                    <el-table-column label="小计" width="100">
                                        <span>{{
                                            calculateTabTotal('purchaseCost')
                                                | num45Filter
                                        }}</span>
                                    </el-table-column>
                                </el-table>
                            </el-tab-pane>
                            <el-tab-pane label="生产成本/商品销售成本">
                                <el-table
                                    :data="form.productionCost"
                                    border
                                    show-summary
                                    :summary-method="getSummaries"
                                    style="width: 100%"
                                    :span-method="
                                        objectSpanMethod_productionCost
                                    "
                                >
                                    <el-table-column
                                        label="生产成本/商品销售成本-投入项"
                                        width="230"
                                    >
                                        <template slot-scope="scope">
                                            <span>{{ scope.row.title }}</span>
                                        </template>
                                    </el-table-column>
                                    <el-table-column
                                        label="标准(平均单价)"
                                        width="140"
                                    >
                                        <template>
                                            <span>——</span>
                                        </template>
                                    </el-table-column>
                                    <el-table-column label="合计" width="100">
                                        <template slot-scope="scope">
                                            <span>{{
                                                calculateSummary(scope.row)
                                                    | num45Filter
                                            }}</span>
                                        </template>
                                    </el-table-column>
                                    <el-table-column
                                        :key="index"
                                        v-for="(p, index) in form.allMonths"
                                        :label="p"
                                        width="100"
                                    >
                                        <template slot-scope="scope">
                                            <span
                                                v-if="
                                                    scope.row.type === 'input'
                                                "
                                                >{{
                                                    scope.row.input[index]
                                                }}</span
                                            >
                                            <span
                                                v-if="scope.row.type === 'span'"
                                                >{{
                                                    scope.row.input[index]
                                                        | num45Filter
                                                }}</span
                                            >
                                        </template>
                                    </el-table-column>
                                    <el-table-column label="小计" width="100">
                                        <span>{{
                                            calculateTabTotal('productionCost')
                                                | num45Filter
                                        }}</span>
                                    </el-table-column>
                                </el-table>
                            </el-tab-pane>
                            <el-tab-pane label="外包成本">
                                <el-table
                                    :data="form.outsourcingProjectCost"
                                    border
                                    show-summary
                                    :summary-method="getSummaries"
                                    style="width: 100%"
                                    :span-method="
                                        objectSpanMethod_outsourcingProjectCost
                                    "
                                >
                                    <el-table-column
                                        label="外包成本-投入项"
                                        width="230"
                                    >
                                        <template slot-scope="scope">
                                            <span>{{ scope.row.title }}</span>
                                        </template>
                                    </el-table-column>
                                    <el-table-column label="" width="140">
                                        <template slot-scope="scope">
                                            <span
                                                v-if="
                                                    scope.row.hasOwnProperty(
                                                        'provider'
                                                    )
                                                "
                                            >
                                                {{ scope.row.provider }}
                                            </span>
                                            <span
                                                v-if="
                                                    scope.row.hasOwnProperty(
                                                        'department'
                                                    )
                                                "
                                                >{{
                                                    scope.row.department
                                                }}</span
                                            >
                                        </template>
                                    </el-table-column>
                                    <el-table-column label="合计" width="100">
                                        <template slot-scope="scope">
                                            <span>{{
                                                calculateSummary(scope.row)
                                                    | num45Filter
                                            }}</span>
                                        </template>
                                    </el-table-column>
                                    <el-table-column
                                        :key="index"
                                        v-for="(p, index) in form.allMonths"
                                        :label="p"
                                        width="100"
                                    >
                                        <template slot-scope="scope">
                                            <span
                                                v-if="
                                                    scope.row.type === 'input'
                                                "
                                                >{{
                                                    scope.row.input[index]
                                                }}</span
                                            >
                                            <span
                                                v-if="scope.row.type === 'span'"
                                                >{{
                                                    scope.row.input[index]
                                                        | num45Filter
                                                }}</span
                                            >
                                        </template>
                                    </el-table-column>
                                    <el-table-column label="小计" width="100">
                                        <span>{{
                                            calculateTabTotal(
                                                'outsourcingProjectCost'
                                            ) | num45Filter
                                        }}</span>
                                    </el-table-column>
                                </el-table>
                            </el-tab-pane>
                            <el-tab-pane label="人力成本">
                                <el-table
                                    :data="form.labourCost"
                                    border
                                    show-summary
                                    :summary-method="getSummaries"
                                    style="width: 100%"
                                    :span-method="objectSpanMethod_labourCost"
                                >
                                    <el-table-column
                                        label="人力成本-投入项"
                                        prop="title"
                                        width="200"
                                    >
                                    </el-table-column>
                                    <el-table-column label="合计" width="100">
                                        <template slot-scope="scope">
                                            <span>{{
                                                calculateManPowerSummary(
                                                    scope.row
                                                ) | num45Filter
                                            }}</span>
                                        </template>
                                    </el-table-column>
                                    <el-table-column
                                        :key="index"
                                        v-for="(p, index) in form.allMonths"
                                        :label="p"
                                        width="120"
                                    >
                                        <template slot-scope="scope">
                                            <span>{{
                                                (scope.row.values[index]
                                                    ? scope.row.values[index]
                                                    : 0) | num45Filter
                                            }}</span>
                                        </template>
                                    </el-table-column>
                                    <el-table-column label="小计" width="100">
                                        <span>{{
                                            calculateTabTotal('labourCost')
                                                | num45Filter
                                        }}</span>
                                    </el-table-column>
                                </el-table>
                                <el-table
                                    :data="form.labourOtherCost"
                                    border
                                    show-summary
                                    :summary-method="getSummaries"
                                    style="width: 100%; margin-top: 25px"
                                >
                                    <el-table-column
                                        label="其它人力"
                                        width="200"
                                    >
                                    </el-table-column>
                                    <el-table-column label="合计" width="100">
                                        <template slot-scope="scope">
                                            <span>{{
                                                 sum(
                                                    scope.row.input.slice(
                                                        -form.nextMonths.length
                                                    )
                                                ) | num45Filter
                                            }}</span>
                                        </template>
                                    </el-table-column>
                                    <el-table-column
                                        :key="p"
                                        v-for="(p, index) in form.pastMonths"
                                        :label="p"
                                        width="120"
                                    >
                                    </el-table-column>
                                    <el-table-column
                                        :key="index"
                                        v-for="(p, index) in form.nextMonths"
                                        :label="p"
                                        width="120"
                                    >
                                        <template slot-scope="scope">
                                            <span>{{
                                                 scope.row.input[
                                                        form.pastMonths.length +
                                                            index
                                                    ]
                                            }}</span>
                                        </template>
                                    </el-table-column>
                                </el-table>
                                <el-table
                                    :data="form.labourOtherCost"
                                    border
                                    show-summary
                                    :summary-method="getSummaries"
                                    style="width: 100%; margin-top: 25px"
                                >
                                    <el-table-column
                                        label="每月合计"
                                        width="300"
                                    >
                                    </el-table-column>
                                    <el-table-column
                                        :key="p"
                                        v-for="(p, index) in form.pastMonths"
                                        :label="p"
                                        width="120"
                                    >
                                        <template slot-scope="scope">
                                            <span>{{
                                                form.historyManPowerInput[1]
                                                    .input[index] | num45Filter
                                            }}</span>
                                        </template>
                                    </el-table-column>
                                    <el-table-column
                                        :key="index"
                                        v-for="(p, index) in form.nextMonths"
                                        :label="p"
                                        width="120"
                                    >
                                        <template slot-scope="scope">
                                            <span>{{
                                                calcLabourMonthColumn(
                                                    index +
                                                        form.pastMonths.length
                                                )
                                            }}</span>
                                        </template>
                                    </el-table-column>
                                </el-table>
                            </el-tab-pane>
                            <el-tab-pane label="国内差旅">
                                <el-row>
                                    <el-table
                                        :data="form.domesticTravel"
                                        border
                                        show-summary
                                        :summary-method="getSummaries"
                                        style="width: 100%"
                                        :span-method="
                                            objectSpanMethod_domesticTravel
                                        "
                                    >
                                        <el-table-column
                                            label="国内差旅-投入项"
                                            width="230"
                                        >
                                            <template slot-scope="scope">
                                                <span>{{
                                                    scope.row.title
                                                }}</span>
                                            </template>
                                        </el-table-column>
                                        <el-table-column
                                            label="合计"
                                            width="100"
                                        >
                                            <template slot-scope="scope">
                                                <span>{{
                                                    calculateSummary(scope.row)
                                                        | num45Filter
                                                }}</span>
                                            </template>
                                        </el-table-column>
                                        <el-table-column
                                            :key="index"
                                            v-for="(p, index) in form.allMonths"
                                            :label="p"
                                            width="100"
                                        >
                                            <template slot-scope="scope">
                                                <span
                                                    v-if="
                                                        scope.row.type ===
                                                        'input'
                                                    "
                                                    >{{
                                                        scope.row.input[index]
                                                    }}</span
                                                >
                                                <span
                                                    v-if="
                                                        scope.row.type ===
                                                        'span'
                                                    "
                                                    >{{
                                                        scope.row.input[index]
                                                            | num45Filter
                                                    }}</span
                                                >
                                            </template>
                                        </el-table-column>
                                        <el-table-column
                                            label="小计"
                                            width="100"
                                        >
                                            <span>{{
                                                calculateTabTotal(
                                                    'domesticTravel'
                                                ) | num45Filter
                                            }}</span>
                                        </el-table-column>
                                    </el-table>
                                </el-row>
                            </el-tab-pane>
                            <el-tab-pane label="国际差旅">
                                <el-row>
                                    <el-table
                                        :data="form.foreignTravel"
                                        border
                                        show-summary
                                        :summary-method="getSummaries"
                                        style="width: 100%"
                                        :span-method="
                                            objectSpanMethod_foreignTravel
                                        "
                                    >
                                        <el-table-column
                                            label="国际差旅-投入项"
                                            width="230"
                                        >
                                            <template slot-scope="scope">
                                                <span>{{
                                                    scope.row.title
                                                }}</span>
                                            </template>
                                        </el-table-column>
                                        <el-table-column
                                            label="合计"
                                            width="100"
                                        >
                                            <template slot-scope="scope">
                                                <span>{{
                                                    calculateSummary(scope.row)
                                                        | num45Filter
                                                }}</span>
                                            </template>
                                        </el-table-column>
                                        <el-table-column
                                            :key="index"
                                            v-for="(p, index) in form.allMonths"
                                            :label="p"
                                            width="100"
                                        >
                                            <template slot-scope="scope">
                                                <span
                                                    v-if="
                                                        scope.row.type ===
                                                        'input'
                                                    "
                                                    >{{
                                                        scope.row.input[index]
                                                    }}</span
                                                >
                                                <span
                                                    v-if="
                                                        scope.row.type ===
                                                        'span'
                                                    "
                                                    >{{
                                                        scope.row.input[index]
                                                            | num45Filter
                                                    }}</span
                                                >
                                            </template>
                                        </el-table-column>
                                        <el-table-column
                                            label="小计"
                                            width="100"
                                        >
                                            <span>{{
                                                calculateTabTotal(
                                                    'foreignTravel'
                                                ) | num45Filter
                                            }}</span>
                                        </el-table-column>
                                    </el-table>
                                </el-row>
                            </el-tab-pane>
                            <el-tab-pane label="租赁费用">
                                <el-row>
                                    <el-table
                                        :data="form.rent"
                                        border
                                        show-summary
                                        :summary-method="getSummaries"
                                        style="width: 100%"
                                        :span-method="objectSpanMethod_rent"
                                    >
                                        <el-table-column
                                            label="租赁费用-投入项"
                                            width="230"
                                        >
                                            <template slot-scope="scope">
                                                <span>{{
                                                    scope.row.title
                                                }}</span>
                                            </template>
                                        </el-table-column>
                                        <el-table-column
                                            label="合计"
                                            width="100"
                                        >
                                            <template slot-scope="scope">
                                                <span>{{
                                                    calculateSummary(scope.row)
                                                        | num45Filter
                                                }}</span>
                                            </template>
                                        </el-table-column>
                                        <el-table-column
                                            :key="index"
                                            v-for="(p, index) in form.allMonths"
                                            :label="p"
                                            width="100"
                                        >
                                            <template slot-scope="scope">
                                                <span
                                                    v-if="
                                                        scope.row.type ===
                                                        'input'
                                                    "
                                                    >{{
                                                        scope.row.input[index]
                                                    }}</span
                                                >
                                                <span
                                                    v-if="
                                                        scope.row.type ===
                                                        'span'
                                                    "
                                                    >{{
                                                        scope.row.input[index]
                                                            | num45Filter
                                                    }}</span
                                                >
                                            </template>
                                        </el-table-column>
                                        <el-table-column
                                            label="小计"
                                            width="100"
                                        >
                                            <span>{{
                                                calculateTabTotal('rent')
                                                    | num45Filter
                                            }}</span>
                                        </el-table-column>
                                    </el-table>
                                </el-row>
                            </el-tab-pane>
                            <el-tab-pane label="运营支出">
                                <el-row>
                                    <el-table
                                        :data="form.operation"
                                        border
                                        show-summary
                                        :summary-method="getSummaries"
                                        style="width: 100%"
                                        :span-method="
                                            objectSpanMethod_operation
                                        "
                                    >
                                        <el-table-column
                                            label="运营支出-投入项"
                                            width="230"
                                        >
                                            <template slot-scope="scope">
                                                <span>{{
                                                    scope.row.title
                                                }}</span>
                                            </template>
                                        </el-table-column>
                                        <el-table-column
                                            label="合计"
                                            width="100"
                                        >
                                            <template slot-scope="scope">
                                                <span>{{
                                                    calculateSummary(scope.row)
                                                        | num45Filter
                                                }}</span>
                                            </template>
                                        </el-table-column>
                                        <el-table-column
                                            :key="index"
                                            v-for="(p, index) in form.allMonths"
                                            :label="p"
                                            width="100"
                                        >
                                            <template slot-scope="scope">
                                                <span
                                                    v-if="
                                                        scope.row.type ===
                                                        'input'
                                                    "
                                                    >{{
                                                        scope.row.input[index]
                                                    }}</span
                                                >

                                                <span
                                                    v-if="
                                                        scope.row.type ===
                                                        'span'
                                                    "
                                                    >{{
                                                        scope.row.input[index]
                                                            | num45Filter
                                                    }}</span
                                                >
                                            </template>
                                        </el-table-column>
                                        <el-table-column
                                            label="小计"
                                            width="100"
                                        >
                                            <span>{{
                                                calculateTabTotal('operation')
                                                    | num45Filter
                                            }}</span>
                                        </el-table-column>
                                    </el-table>
                                </el-row>
                            </el-tab-pane>
                            <el-tab-pane label="IT支出">
                                <el-row>
                                    <el-table
                                        :data="form.it_cost"
                                        border
                                        show-summary
                                        :summary-method="getSummaries"
                                        style="width: 100%"
                                        :span-method="objectSpanMethod_it"
                                    >
                                        <el-table-column
                                            label="IT支出-投入项"
                                            width="230"
                                        >
                                            <template slot-scope="scope">
                                                <span>{{
                                                    scope.row.title
                                                }}</span>
                                            </template>
                                        </el-table-column>
                                        <el-table-column
                                            label="合计"
                                            width="100"
                                        >
                                            <template slot-scope="scope">
                                                <span>{{
                                                    calculateSummary(scope.row)
                                                        | num45Filter
                                                }}</span>
                                            </template>
                                        </el-table-column>
                                        <el-table-column
                                            :key="index"
                                            v-for="(p, index) in form.allMonths"
                                            :label="p"
                                            width="100"
                                        >
                                            <template slot-scope="scope">
                                                <span
                                                    v-if="
                                                        scope.row.type ===
                                                        'input'
                                                    "
                                                    >{{
                                                        scope.row.input[index]
                                                    }}</span
                                                >
                                                <span
                                                    v-if="
                                                        scope.row.type ===
                                                        'span'
                                                    "
                                                    >{{
                                                        scope.row.input[index]
                                                            | num45Filter
                                                    }}</span
                                                >
                                            </template>
                                        </el-table-column>
                                        <el-table-column
                                            label="小计"
                                            width="100"
                                        >
                                            <span>{{
                                                calculateTabTotal('it_cost')
                                                    | num45Filter
                                            }}</span>
                                        </el-table-column>
                                    </el-table>
                                </el-row>
                            </el-tab-pane>
                            <el-tab-pane label="折旧与摊销">
                                <el-row>
                                    <el-table
                                        :data="form.depreciation"
                                        border
                                        show-summary
                                        :summary-method="getSummaries"
                                        style="width: 100%"
                                        :span-method="
                                            objectSpanMethod_depreciation
                                        "
                                    >
                                        <el-table-column
                                            label="折旧与摊销-投入项"
                                            width="230"
                                        >
                                            <template slot-scope="scope">
                                                <span>{{
                                                    scope.row.title
                                                }}</span>
                                            </template>
                                        </el-table-column>
                                        <el-table-column
                                            label="合计"
                                            width="100"
                                        >
                                            <template slot-scope="scope">
                                                <span>{{
                                                    calculateSummary(scope.row)
                                                        | num45Filter
                                                }}</span>
                                            </template>
                                        </el-table-column>
                                        <el-table-column
                                            :key="index"
                                            v-for="(p, index) in form.allMonths"
                                            :label="p"
                                            width="100"
                                        >
                                            <template slot-scope="scope">
                                                <span
                                                    v-if="
                                                        scope.row.type ===
                                                        'input'
                                                    "
                                                    >{{
                                                        scope.row.input[index]
                                                    }}</span
                                                >

                                                <span
                                                    v-if="
                                                        scope.row.type ===
                                                        'span'
                                                    "
                                                    >{{
                                                        scope.row.input[index]
                                                            | num45Filter
                                                    }}</span
                                                >
                                            </template>
                                        </el-table-column>
                                        <el-table-column
                                            label="小计"
                                            width="100"
                                        >
                                            <span>{{
                                                calculateTabTotal(
                                                    'depreciation'
                                                ) | num45Filter
                                            }}</span>
                                        </el-table-column>
                                    </el-table>
                                </el-row>
                            </el-tab-pane>
                            <el-tab-pane label="固定资产购买">
                                <el-row>
                                    <el-table
                                        :data="form.assets"
                                        border
                                        show-summary
                                        :summary-method="getSummaries"
                                        style="width: 100%"
                                        :span-method="objectSpanMethod_assets"
                                    >
                                        <el-table-column
                                            label="固定资产购买-投入项"
                                            width="230"
                                        >
                                            <template slot-scope="scope">
                                                <span>{{
                                                    scope.row.title
                                                }}</span>
                                            </template>
                                        </el-table-column>
                                        <el-table-column
                                            label="合计"
                                            width="100"
                                        >
                                            <template slot-scope="scope">
                                                <span>{{
                                                    calculateSummary(scope.row)
                                                        | num45Filter
                                                }}</span>
                                            </template>
                                        </el-table-column>
                                        <el-table-column
                                            :key="index"
                                            v-for="(p, index) in form.allMonths"
                                            :label="p"
                                            width="100"
                                        >
                                            <template slot-scope="scope">
                                                <span
                                                    v-if="
                                                        scope.row.type ===
                                                        'input'
                                                    "
                                                    >{{
                                                        scope.row.input[index]
                                                    }}</span
                                                >
                                                <span
                                                    v-if="
                                                        scope.row.type ===
                                                        'span'
                                                    "
                                                    >{{
                                                        scope.row.input[index]
                                                            | num45Filter
                                                    }}</span
                                                >
                                            </template>
                                        </el-table-column>
                                        <el-table-column
                                            label="小计"
                                            width="100"
                                        >
                                            <span>{{
                                                calculateTabTotal('assets')
                                                    | num45Filter
                                            }}</span>
                                        </el-table-column>
                                    </el-table>
                                </el-row>
                            </el-tab-pane>
                            <el-tab-pane label="无形资产购买">
                                <el-row>
                                    <el-table
                                        :data="form.immaterial"
                                        border
                                        style="width: 100%"
                                        :span-method="
                                            objectSpanMethod_immaterial
                                        "
                                    >
                                        <el-table-column
                                            label="无形资产购买-投入项"
                                            width="230"
                                        >
                                            <template slot-scope="scope">
                                                <span>{{
                                                    scope.row.title
                                                }}</span>
                                            </template>
                                        </el-table-column>
                                        <el-table-column
                                            label="合计"
                                            width="100"
                                        >
                                            <template slot-scope="scope">
                                                <span>{{
                                                    calculateSummary(scope.row)
                                                        | num45Filter
                                                }}</span>
                                            </template>
                                        </el-table-column>
                                        <el-table-column
                                            :key="index"
                                            v-for="(p, index) in form.allMonths"
                                            :label="p"
                                            width="100"
                                        >
                                            <template slot-scope="scope">
                                                <span
                                                    v-if="
                                                        scope.row.type ===
                                                        'input'
                                                    "
                                                    >{{
                                                        scope.row.input[index]
                                                    }}</span
                                                >

                                                <span
                                                    v-if="
                                                        scope.row.type ===
                                                        'span'
                                                    "
                                                    >{{
                                                        scope.row.input[index]
                                                            | num45Filter
                                                    }}</span
                                                >
                                            </template>
                                        </el-table-column>
                                        <el-table-column
                                            label="小计"
                                            width="100"
                                        >
                                            <span>{{
                                                calculateTabTotal('immaterial')
                                                    | num45Filter
                                            }}</span>
                                        </el-table-column>
                                    </el-table>
                                </el-row>
                            </el-tab-pane>
                        </el-tabs>
                        <div slot="footer" class="dialog-footer">
                            <el-button @click="financeTableExcDialog = false"
                                >取 消</el-button
                            >
                            <el-button
                                type="success"
                                plain
                                @click="financeTableExc"
                                >下 载</el-button
                            >
                        </div>
                    </el-dialog>
                    <div>
                        <el-tabs tab-position="left" :disabled="!canEdit">
                            <el-tab-pane label="项目收入">
                                <el-table
                                    :data="form.projectIncome"
                                    border
                                    style="width: 100%"
                                    :cell-class-name="addClass_income"
                                    :row-class-name="tableRowIndex"
                                    @cell-dblclick="selectCell_income"
                                >
                                    <el-table-column label="投入项" width="230">
                                        <template slot-scope="scope">
                                            <span>{{ scope.row.title }}</span>
                                        </template>
                                    </el-table-column>
                                    <el-table-column
                                        label="标准(平均单价)"
                                        width="140"
                                    >
                                        <template slot-scope="scope">
                                            <el-input
                                                v-if="
                                                    scope.row.field ===
                                                    'nre_offer_per_unit'
                                                "
                                                size="mini"
                                                :disabled="!canEdit"
                                                placeholder=""
                                                v-model="scope.row.value"
                                                @input="
                                                    calculateQuotation(
                                                        scope.row,
                                                        0,
                                                        scope.$index
                                                    )
                                                "
                                                oninput="value=value.replace(/^0[0-9]|[^\d.]/g,'')"
                                            >
                                            </el-input>
                                            <span v-else>——</span>
                                        </template>
                                    </el-table-column>
                                    <el-table-column label="合计" width="100">
                                        <template slot-scope="scope">
                                            <span
                                                v-if="
                                                    scope.row.field !=
                                                    'nre_offer_per_unit'
                                                "
                                            >
                                                <span
                                                    v-if="
                                                        scope.row.field ==
                                                            'nre_income_rmb' ||
                                                        scope.row.field ==
                                                            'royalty_rmb' ||
                                                        scope.row.field ==
                                                            'training_rmb' ||
                                                        scope.row.field ==
                                                            'internal_outsourcing_rmb' ||
                                                        scope.row.field ==
                                                            'other_rmb'
                                                    "
                                                >
                                                    {{
                                                        (calculateSummary(
                                                            scope.row
                                                        ) *
                                                            form.currency)
                                                            | num45Filter
                                                    }}
                                                </span>
                                                <span v-else>
                                                    {{
                                                        calculateSummary(
                                                            scope.row
                                                        ) | num45Filter
                                                    }}
                                                </span>
                                            </span>
                                        </template>
                                    </el-table-column>
                                    <el-table-column
                                        :key="index"
                                        v-for="(p, index) in form.allMonths"
                                        :label="p"
                                        width="100"
                                        type="cell"
                                        :index="index"
                                    >
                                        <template slot-scope="scope">
                                            <el-input
                                                v-if="
                                                    scope.row.type ===
                                                        'input' &&
                                                    scope.row.field !=
                                                        'nre_offer_per_unit'
                                                "
                                                size="mini"
                                                :disabled="!canEdit"
                                                placeholder=""
                                                v-model="scope.row.input[index]"
                                                @input="
                                                    calculateQuotation(
                                                        scope.row,
                                                        index,
                                                        scope.$index
                                                    )
                                                "
                                                oninput="value=value.replace(/^0[0-9]|[^\d.]/g,'')"
                                            >
                                            </el-input>
                                            <span
                                                v-if="
                                                    scope.row.type === 'span' &&
                                                    scope.row.field !==
                                                        'nre_income'
                                                "
                                                >{{
                                                    (scope.row.input[index] *
                                                        form.currency)
                                                        | num45Filter
                                                }}</span
                                            >
                                            <span
                                                v-if="
                                                    scope.row.type === 'span' &&
                                                    scope.row.field ===
                                                        'nre_income'
                                                "
                                                >{{
                                                    scope.row.input[index]
                                                        | num45Filter
                                                }}</span
                                            >
                                        </template>
                                    </el-table-column>
                                </el-table>
                            </el-tab-pane>
                            <el-tab-pane label="采购成本/商品销售成本">
                                <el-table
                                    :data="form.purchaseCost"
                                    border
                                    style="width: 100%"
                                >
                                    <el-table-column label="投入项" width="230">
                                        <template slot-scope="scope">
                                            <span>{{ scope.row.title }}</span>
                                        </template>
                                    </el-table-column>
                                    <el-table-column
                                        label="标准(平均单价)"
                                        width="140"
                                    >
                                        <template>
                                            <span>——</span>
                                        </template>
                                    </el-table-column>
                                    <el-table-column label="合计" width="100">
                                        <template slot-scope="scope">
                                            <span>{{
                                                calculateSummary(scope.row)
                                                    | num45Filter
                                            }}</span>
                                        </template>
                                    </el-table-column>
                                    <el-table-column
                                        :key="index"
                                        v-for="(p, index) in form.allMonths"
                                        :label="p"
                                        width="100"
                                    >
                                        <template slot-scope="scope">
                                            <el-input
                                                v-if="
                                                    scope.row.type === 'input'
                                                "
                                                size="mini"
                                                :disabled="!canEdit"
                                                placeholder=""
                                                v-model="scope.row.input[index]"
                                                @input="
                                                    calculateQuotation(
                                                        scope.row,
                                                        index,
                                                        scope.$index
                                                    )
                                                "
                                                oninput="value=value.replace(/^0[0-9]|[^\d.]/g,'')"
                                            >
                                            </el-input>
                                            <span
                                                v-if="scope.row.type === 'span'"
                                                >{{
                                                    scope.row.input[index]
                                                        | num45Filter
                                                }}</span
                                            >
                                        </template>
                                    </el-table-column>
                                </el-table>
                                <div style="margin: 30px 5px">
                                    小计：{{
                                        calculateTabTotal('purchaseCost')
                                            | num45Filter
                                    }}
                                </div>
                            </el-tab-pane>
                            <el-tab-pane label="生产成本/商品销售成本">
                                <el-table
                                    :data="form.productionCost"
                                    border
                                    style="width: 100%"
                                >
                                    <el-table-column label="投入项" width="230">
                                        <template slot-scope="scope">
                                            <span>{{ scope.row.title }}</span>
                                        </template>
                                    </el-table-column>
                                    <el-table-column
                                        label="标准(平均单价)"
                                        width="140"
                                    >
                                        <template>
                                            <span>——</span>
                                        </template>
                                    </el-table-column>
                                    <el-table-column label="合计" width="100">
                                        <template slot-scope="scope">
                                            <span>{{
                                                calculateSummary(scope.row)
                                                    | num45Filter
                                            }}</span>
                                        </template>
                                    </el-table-column>
                                    <el-table-column
                                        :key="index"
                                        v-for="(p, index) in form.allMonths"
                                        :label="p"
                                        width="100"
                                    >
                                        <template slot-scope="scope">
                                            <el-input
                                                v-if="
                                                    scope.row.type === 'input'
                                                "
                                                size="mini"
                                                :disabled="!canEdit"
                                                placeholder=""
                                                v-model="scope.row.input[index]"
                                                @input="
                                                    calculateQuotation(
                                                        scope.row,
                                                        index,
                                                        scope.$index
                                                    )
                                                "
                                                oninput="value=value.replace(/^0[0-9]|[^\d.]/g,'')"
                                            >
                                            </el-input>
                                            <span
                                                v-if="scope.row.type === 'span'"
                                                >{{
                                                    scope.row.input[index]
                                                        | num45Filter
                                                }}</span
                                            >
                                        </template>
                                    </el-table-column>
                                </el-table>
                                <div style="margin: 30px 5px">
                                    小计：{{
                                        calculateTabTotal('productionCost')
                                            | num45Filter
                                    }}
                                </div>
                            </el-tab-pane>
                            <el-tab-pane label="外包成本">
                                <el-table
                                    :data="form.outsourcingProjectCost"
                                    border
                                    style="width: 100%"
                                >
                                    <el-table-column label="投入项" width="230">
                                        <template slot-scope="scope">
                                            <span>{{ scope.row.title }}</span>
                                        </template>
                                    </el-table-column>
                                    <el-table-column label="" width="140">
                                        <template slot-scope="scope">
                                            <el-input
                                                :placeholder="
                                                    scope.row.placeholder
                                                "
                                                :disabled="!canEdit"
                                                v-if="
                                                    scope.row.hasOwnProperty(
                                                        'provider'
                                                    )
                                                "
                                                v-model="scope.row.provider"
                                            ></el-input>
                                            <el-input
                                                :placeholder="
                                                    scope.row.placeholder
                                                "
                                                :disabled="!canEdit"
                                                v-if="
                                                    scope.row.hasOwnProperty(
                                                        'department'
                                                    )
                                                "
                                                v-model="scope.row.department"
                                            ></el-input>
                                        </template>
                                    </el-table-column>
                                    <el-table-column label="合计" width="100">
                                        <template slot-scope="scope">
                                            <span>{{
                                                calculateSummary(scope.row)
                                                    | num45Filter
                                            }}</span>
                                        </template>
                                    </el-table-column>
                                    <el-table-column
                                        :key="index"
                                        v-for="(p, index) in form.allMonths"
                                        :label="p"
                                        width="100"
                                    >
                                        <template slot-scope="scope">
                                            <el-input
                                                v-if="
                                                    scope.row.type === 'input'
                                                "
                                                size="mini"
                                                :disabled="!canEdit"
                                                placeholder=""
                                                v-model="scope.row.input[index]"
                                                @input="
                                                    calculateQuotation(
                                                        scope.row,
                                                        index,
                                                        scope.$index
                                                    )
                                                "
                                                oninput="value=value.replace(/^0[0-9]|[^\d.]/g,'')"
                                            >
                                            </el-input>
                                            <span
                                                v-if="scope.row.type === 'span'"
                                                >{{
                                                    scope.row.input[index]
                                                        | num45Filter
                                                }}</span
                                            >
                                        </template>
                                    </el-table-column>
                                </el-table>
                                <div style="margin: 30px 5px">
                                    小计：{{
                                        calculateTabTotal(
                                            'outsourcingProjectCost'
                                        ) | num45Filter
                                    }}
                                </div>
                            </el-tab-pane>
                            <el-tab-pane label="人力成本">
                                <el-row>
                                    <span
                                        class="input-label"
                                        style="width: 200px"
                                        >社保及住房公积金比例</span
                                    >
                                    <el-input
                                        oninput="value=value.replace(/^0[0-9]|[^\d.-],'')"
                                        :disabled="!canEdit"
                                        v-model="form.housing_fund_rate"
                                        style="width: 150px"
                                        @change="calculateTotalManMonth()"
                                    >
                                        <template slot="append">%</template>
                                    </el-input>
                                </el-row>
                                <el-table
                                    :data="form.labourCost"
                                    border
                                    style="width: 100%"
                                >
                                    <el-table-column
                                        label=""
                                        prop="title"
                                        width="200"
                                    >
                                    </el-table-column>
                                    <el-table-column label="合计" width="100">
                                        <template slot-scope="scope">
                                            <span>{{
                                                calculateManPowerSummary(
                                                    scope.row
                                                ) | num45Filter
                                            }}</span>
                                        </template>
                                    </el-table-column>
                                    <el-table-column
                                        :key="'mpn_' + index.toString()"
                                        v-for="(p, index) in form.allMonths"
                                        :label="p"
                                        width="120"
                                    >
                                        <template slot-scope="scope">
                                            <span>{{
                                                (scope.row.values[index]
                                                    ? scope.row.values[index]
                                                    : 0) | num45Filter
                                            }}</span>
                                        </template>
                                    </el-table-column>
                                </el-table>
                                <el-table
                                    :data="form.labourOtherCost"
                                    border
                                    style="width: 100%; margin-top: 25px"
                                >
                                    <el-table-column
                                        label="其它人力"
                                        width="200"
                                    >
                                    </el-table-column>
                                    <el-table-column label="合计" width="100">
                                        <template slot-scope="scope">
                                            <span>{{
                                                sum(
                                                    scope.row.input.slice(
                                                        -form.nextMonths.length
                                                    )
                                                ) | num45Filter
                                            }}</span>
                                        </template>
                                    </el-table-column>
                                    <el-table-column
                                        :key="p"
                                        v-for="(p, index) in form.pastMonths"
                                        :label="p"
                                        width="120"
                                    >
                                    </el-table-column>
                                    <el-table-column
                                        :key="index"
                                        v-for="(p, index) in form.nextMonths"
                                        :label="p"
                                        width="120"
                                    >
                                        <template slot-scope="scope">
                                            <el-input
                                                size="mini"
                                                :disabled="!canEdit"
                                                placeholder=""
                                                oninput="value=value.replace(/^0[0-9]|[^\d.-]/g,'')"
                                                v-model="
                                                    scope.row.input[
                                                        form.pastMonths.length +
                                                            index
                                                    ]
                                                "
                                                @change="
                                                    calculateTotalManMonth()
                                                "
                                            >
                                            </el-input>
                                        </template>
                                    </el-table-column>
                                </el-table>
                                <el-table
                                    :data="form.labourOtherCost"
                                    border
                                    style="width: 100%; margin-top: 25px"
                                >
                                    <el-table-column
                                        label="每月合计"
                                        width="300"
                                    >
                                    </el-table-column>
                                    <el-table-column
                                        :key="p"
                                        v-for="(p, index) in form.pastMonths"
                                        :label="p"
                                        width="120"
                                    >
                                        <template slot-scope="scope">
                                            <span>{{
                                                form.historyManPowerInput[1]
                                                    .input[index] | num45Filter
                                            }}</span>
                                        </template>
                                    </el-table-column>
                                    <el-table-column
                                        :key="index"
                                        v-for="(p, index) in form.nextMonths"
                                        :label="p"
                                        width="120"
                                    >
                                        <template slot-scope="scope">
                                            <span>{{
                                                calcLabourMonthColumn(
                                                    index +
                                                        form.pastMonths.length
                                                )
                                            }}</span>
                                        </template>
                                    </el-table-column>
                                </el-table>
                                <div style="margin: 30px 5px">
                                    小计：{{
                                        calculateTabTotal('labourCost')
                                            | num45Filter
                                    }}
                                </div>
                            </el-tab-pane>
                            <el-tab-pane label="国内差旅">
                                <el-form
                                    :inline="true"
                                    :model="form"
                                    class="demo-form-inline"
                                >
                                    <el-form-item label="国内住宿(标间/晚)">
                                        <el-input
                                            v-model="
                                                form.constants
                                                    .domestic_accommodation
                                            "
                                            :disabled="!canEdit"
                                            @input="calculateTravel"
                                            placeholder=""
                                        ></el-input>
                                    </el-form-item>
                                    <el-form-item
                                        label="国内机票/火车/汽车(往返一次的标准)"
                                    >
                                        <el-input
                                            v-model="
                                                form.constants
                                                    .domestic_transportation
                                            "
                                            @input="calculateTravel"
                                            :disabled="!canEdit"
                                            placeholder=""
                                        ></el-input>
                                    </el-form-item>
                                    <el-form-item label="国内餐费+差补">
                                        <el-input
                                            v-model="
                                                form.constants.domestic_meals
                                            "
                                            @input="calculateTravel"
                                            :disabled="!canEdit"
                                            placeholder=""
                                        ></el-input>
                                    </el-form-item>
                                </el-form>
                                <el-row>
                                    <el-table
                                        :data="form.domesticTravel"
                                        border
                                        style="width: 100%"
                                    >
                                        <el-table-column
                                            label="投入项"
                                            width="230"
                                        >
                                            <template slot-scope="scope">
                                                <span>{{
                                                    scope.row.title
                                                }}</span>
                                            </template>
                                        </el-table-column>
                                        <el-table-column
                                            label="合计"
                                            width="100"
                                        >
                                            <template slot-scope="scope">
                                                <span>{{
                                                    calculateSummary(scope.row)
                                                        | num45Filter
                                                }}</span>
                                            </template>
                                        </el-table-column>
                                        <el-table-column
                                            :key="index"
                                            v-for="(p, index) in form.allMonths"
                                            :label="p"
                                            width="100"
                                        >
                                            <template slot-scope="scope">
                                                <el-input
                                                    v-if="
                                                        scope.row.type ===
                                                        'input'
                                                    "
                                                    size="mini"
                                                    :disabled="!canEdit"
                                                    placeholder=""
                                                    v-model="
                                                        scope.row.input[index]
                                                    "
                                                    @input="
                                                        calculateQuotation(
                                                            scope.row,
                                                            index,
                                                            scope.$index
                                                        )
                                                    "
                                                    oninput="value=value.replace(/^0[0-9]|[^\d.]/g,'')"
                                                >
                                                </el-input>
                                                <span
                                                    v-if="
                                                        scope.row.type ===
                                                        'span'
                                                    "
                                                    >{{
                                                        scope.row.input[index]
                                                            | num45Filter
                                                    }}</span
                                                >
                                            </template>
                                        </el-table-column>
                                    </el-table>
                                </el-row>
                                <div style="margin: 30px 5px">
                                    小计：{{
                                        calculateTabTotal('domesticTravel')
                                            | num45Filter
                                    }}
                                </div>
                            </el-tab-pane>
                            <el-tab-pane label="国际差旅">
                                <el-form
                                    :inline="true"
                                    :model="form"
                                    class="demo-form-inline"
                                >
                                    <el-form-item label="国际住宿(标间/晚)">
                                        <el-input
                                            v-model="
                                                form.constants
                                                    .foreign_accommodation
                                            "
                                            @input="calculateTravel"
                                            :disabled="!canEdit"
                                            placeholder=""
                                        ></el-input>
                                    </el-form-item>
                                    <el-form-item
                                        label="国际机票/火车/汽车(往返一次的标准)"
                                    >
                                        <el-input
                                            v-model="
                                                form.constants
                                                    .foreign_transportation
                                            "
                                            @input="calculateTravel"
                                            :disabled="!canEdit"
                                            placeholder=""
                                        ></el-input>
                                    </el-form-item>
                                    <el-form-item label="国际餐费+差补">
                                        <el-input
                                            v-model="
                                                form.constants.foreign_meals
                                            "
                                            @input="calculateTravel"
                                            :disabled="!canEdit"
                                            placeholder=""
                                        ></el-input>
                                    </el-form-item>
                                    <el-form-item label="签证护照费">
                                        <el-input
                                            v-model="form.constants.visa"
                                            placeholder=""
                                            :disabled="!canEdit"
                                            @input="calculateTravel"
                                        ></el-input>
                                    </el-form-item>
                                </el-form>
                                <el-row>
                                    <el-table
                                        :data="form.foreignTravel"
                                        border
                                        style="width: 100%"
                                    >
                                        <el-table-column
                                            label="投入项"
                                            width="230"
                                        >
                                            <template slot-scope="scope">
                                                <span>{{
                                                    scope.row.title
                                                }}</span>
                                            </template>
                                        </el-table-column>
                                        <el-table-column
                                            label="合计"
                                            width="100"
                                        >
                                            <template slot-scope="scope">
                                                <span>{{
                                                    calculateSummary(scope.row)
                                                        | num45Filter
                                                }}</span>
                                            </template>
                                        </el-table-column>
                                        <el-table-column
                                            :key="index"
                                            v-for="(p, index) in form.allMonths"
                                            :label="p"
                                            width="100"
                                        >
                                            <template slot-scope="scope">
                                                <el-input
                                                    v-if="
                                                        scope.row.type ===
                                                        'input'
                                                    "
                                                    size="mini"
                                                    :disabled="!canEdit"
                                                    placeholder=""
                                                    v-model="
                                                        scope.row.input[index]
                                                    "
                                                    @input="
                                                        calculateQuotation(
                                                            scope.row,
                                                            index,
                                                            scope.$index
                                                        )
                                                    "
                                                    oninput="value=value.replace(/^0[0-9]|[^\d.]/g,'')"
                                                >
                                                </el-input>
                                                <span
                                                    v-if="
                                                        scope.row.type ===
                                                        'span'
                                                    "
                                                    >{{
                                                        scope.row.input[index]
                                                            | num45Filter
                                                    }}</span
                                                >
                                            </template>
                                        </el-table-column>
                                    </el-table>
                                </el-row>
                                <div style="margin: 30px 5px">
                                    小计：{{
                                        calculateTabTotal('foreignTravel')
                                            | num45Filter
                                    }}
                                </div>
                            </el-tab-pane>
                            <el-tab-pane label="租赁费用">
                                <el-row>
                                    <el-table
                                        :data="form.rent"
                                        border
                                        style="width: 100%"
                                    >
                                        <el-table-column
                                            label="投入项"
                                            width="230"
                                        >
                                            <template slot-scope="scope">
                                                <span>{{
                                                    scope.row.title
                                                }}</span>
                                            </template>
                                        </el-table-column>
                                        <el-table-column
                                            label="合计"
                                            width="100"
                                        >
                                            <template slot-scope="scope">
                                                <span>{{
                                                    calculateSummary(scope.row)
                                                        | num45Filter
                                                }}</span>
                                            </template>
                                        </el-table-column>
                                        <el-table-column
                                            :key="index"
                                            v-for="(p, index) in form.allMonths"
                                            :label="p"
                                            width="100"
                                        >
                                            <template slot-scope="scope">
                                                <el-input
                                                    v-if="
                                                        scope.row.type ===
                                                        'input'
                                                    "
                                                    size="mini"
                                                    :disabled="!canEdit"
                                                    placeholder=""
                                                    v-model="
                                                        scope.row.input[index]
                                                    "
                                                    @input="
                                                        calculateQuotation(
                                                            scope.row,
                                                            index,
                                                            scope.$index
                                                        )
                                                    "
                                                    oninput="value=value.replace(/^0[0-9]|[^\d.]/g,'')"
                                                >
                                                </el-input>
                                                <span
                                                    v-if="
                                                        scope.row.type ===
                                                        'span'
                                                    "
                                                    >{{
                                                        scope.row.input[index]
                                                            | num45Filter
                                                    }}</span
                                                >
                                            </template>
                                        </el-table-column>
                                    </el-table>
                                </el-row>
                                <div style="margin: 30px 5px">
                                    小计：{{
                                        calculateTabTotal('rent') | num45Filter
                                    }}
                                </div>
                            </el-tab-pane>
                            <el-tab-pane label="运营支出">
                                <el-row>
                                    <el-table
                                        :data="form.operation"
                                        border
                                        style="width: 100%"
                                    >
                                        <el-table-column
                                            label="投入项"
                                            width="230"
                                        >
                                            <template slot-scope="scope">
                                                <span>{{
                                                    scope.row.title
                                                }}</span>
                                            </template>
                                        </el-table-column>
                                        <el-table-column
                                            label="合计"
                                            width="100"
                                        >
                                            <template slot-scope="scope">
                                                <span>{{
                                                    calculateSummary(scope.row)
                                                        | num45Filter
                                                }}</span>
                                            </template>
                                        </el-table-column>
                                        <el-table-column
                                            :key="index"
                                            v-for="(p, index) in form.allMonths"
                                            :label="p"
                                            width="100"
                                        >
                                            <template slot-scope="scope">
                                                <el-input
                                                    v-if="
                                                        scope.row.type ===
                                                        'input'
                                                    "
                                                    size="mini"
                                                    :disabled="!canEdit"
                                                    placeholder=""
                                                    v-model="
                                                        scope.row.input[index]
                                                    "
                                                    oninput="value=value.replace(/^0[0-9]|[^\d.]/g,'')"
                                                    @input="
                                                        calculateQuotation(
                                                            scope.row,
                                                            index,
                                                            scope.$index
                                                        )
                                                    "
                                                >
                                                </el-input>
                                                <span
                                                    v-if="
                                                        scope.row.type ===
                                                        'span'
                                                    "
                                                    >{{
                                                        scope.row.input[index]
                                                            | num45Filter
                                                    }}</span
                                                >
                                            </template>
                                        </el-table-column>
                                    </el-table>
                                </el-row>
                                <div style="margin: 30px 5px">
                                    小计：{{
                                        calculateTabTotal('operation')
                                            | num45Filter
                                    }}
                                </div>
                            </el-tab-pane>
                            <el-tab-pane label="IT支出">
                                <el-row>
                                    <el-table
                                        :data="form.it_cost"
                                        border
                                        style="width: 100%"
                                    >
                                        <el-table-column
                                            label="投入项"
                                            width="230"
                                        >
                                            <template slot-scope="scope">
                                                <span>{{
                                                    scope.row.title
                                                }}</span>
                                            </template>
                                        </el-table-column>
                                        <el-table-column
                                            label="合计"
                                            width="100"
                                        >
                                            <template slot-scope="scope">
                                                <span>{{
                                                    calculateSummary(scope.row)
                                                        | num45Filter
                                                }}</span>
                                            </template>
                                        </el-table-column>
                                        <el-table-column
                                            :key="index"
                                            v-for="(p, index) in form.allMonths"
                                            :label="p"
                                            width="100"
                                        >
                                            <template slot-scope="scope">
                                                <el-input
                                                    v-if="
                                                        scope.row.type ===
                                                        'input'
                                                    "
                                                    size="mini"
                                                    :disabled="!canEdit"
                                                    placeholder=""
                                                    v-model="
                                                        scope.row.input[index]
                                                    "
                                                    oninput="value=value.replace(/^0[0-9]|[^\d.]/g,'')"
                                                    @input="
                                                        calculateQuotation(
                                                            scope.row,
                                                            index,
                                                            scope.$index
                                                        )
                                                    "
                                                >
                                                </el-input>
                                                <span
                                                    v-if="
                                                        scope.row.type ===
                                                        'span'
                                                    "
                                                    >{{
                                                        scope.row.input[index]
                                                            | num45Filter
                                                    }}</span
                                                >
                                            </template>
                                        </el-table-column>
                                    </el-table>
                                </el-row>
                                <div style="margin: 30px 5px">
                                    小计：{{
                                        calculateTabTotal('it_cost')
                                            | num45Filter
                                    }}
                                </div>
                            </el-tab-pane>
                            <el-tab-pane label="折旧与摊销">
                                <el-form
                                    :inline="true"
                                    :model="form"
                                    class="demo-form-inline"
                                >
                                    <el-form-item label="房租及物业管理费摊销">
                                        <el-input
                                            v-model="
                                                form.constants.depreciation_rent
                                            "
                                            @input="calculateDepreciation"
                                            :disabled="!canEdit"
                                            placeholder=""
                                        ></el-input>
                                    </el-form-item>
                                    <el-form-item label="装修费摊销">
                                        <el-input
                                            v-model="
                                                form.constants
                                                    .depreciation_renovation
                                            "
                                            @input="calculateDepreciation"
                                            :disabled="!canEdit"
                                            placeholder=""
                                        ></el-input>
                                    </el-form-item>
                                    <el-form-item label="房屋建筑物折旧">
                                        <el-input
                                            v-model="
                                                form.constants
                                                    .depreciation_house
                                            "
                                            @input="calculateDepreciation"
                                            :disabled="!canEdit"
                                            placeholder=""
                                        ></el-input>
                                    </el-form-item>
                                    <el-form-item label="电脑折旧">
                                        <el-input
                                            v-model="
                                                form.constants
                                                    .depreciation_computer
                                            "
                                            disabled
                                            placeholder=""
                                        ></el-input>
                                    </el-form-item>
                                </el-form>
                                <el-row>
                                    <el-table
                                        :data="form.depreciation"
                                        border
                                        style="width: 100%"
                                    >
                                        <el-table-column
                                            label="投入项"
                                            width="230"
                                        >
                                            <template slot-scope="scope">
                                                <span>{{
                                                    scope.row.title
                                                }}</span>
                                            </template>
                                        </el-table-column>
                                        <el-table-column
                                            label="合计"
                                            width="100"
                                        >
                                            <template slot-scope="scope">
                                                <span>{{
                                                    calculateSummary(scope.row)
                                                        | num45Filter
                                                }}</span>
                                            </template>
                                        </el-table-column>
                                        <el-table-column
                                            :key="index"
                                            v-for="(p, index) in form.allMonths"
                                            :label="p"
                                            width="100"
                                        >
                                            <template slot-scope="scope">
                                                <el-input
                                                    v-if="
                                                        scope.row.type ===
                                                        'input'
                                                    "
                                                    size="mini"
                                                    :disabled="!canEdit"
                                                    placeholder=""
                                                    v-model="
                                                        scope.row.input[index]
                                                    "
                                                    @input="
                                                        calculateQuotation(
                                                            scope.row,
                                                            index,
                                                            scope.$index
                                                        )
                                                    "
                                                    oninput="value=value.replace(/^0[0-9]|[^\d.]/g,'')"
                                                >
                                                </el-input>
                                                <span
                                                    v-if="
                                                        scope.row.type ===
                                                        'span'
                                                    "
                                                    >{{
                                                        scope.row.input[index]
                                                            | num45Filter
                                                    }}</span
                                                >
                                            </template>
                                        </el-table-column>
                                    </el-table>
                                </el-row>
                                <div style="margin: 30px 5px">
                                    小计：{{
                                        calculateTabTotal('depreciation')
                                            | num45Filter
                                    }}
                                </div>
                            </el-tab-pane>
                            <el-tab-pane label="固定资产购买">
                                <el-row>
                                    <el-table
                                        :data="form.assets"
                                        border
                                        style="width: 100%"
                                    >
                                        <el-table-column
                                            label="投入项"
                                            width="230"
                                        >
                                            <template slot-scope="scope">
                                                <span>{{
                                                    scope.row.title
                                                }}</span>
                                            </template>
                                        </el-table-column>
                                        <el-table-column
                                            label="合计"
                                            width="100"
                                        >
                                            <template slot-scope="scope">
                                                <span>{{
                                                    calculateSummary(scope.row)
                                                        | num45Filter
                                                }}</span>
                                            </template>
                                        </el-table-column>
                                        <el-table-column
                                            :key="index"
                                            v-for="(p, index) in form.allMonths"
                                            :label="p"
                                            width="100"
                                        >
                                            <template slot-scope="scope">
                                                <el-input
                                                    v-if="
                                                        scope.row.type ===
                                                        'input'
                                                    "
                                                    size="mini"
                                                    :disabled="!canEdit"
                                                    placeholder=""
                                                    v-model="
                                                        scope.row.input[index]
                                                    "
                                                    @input="
                                                        calculateQuotation(
                                                            scope.row,
                                                            index,
                                                            scope.$index
                                                        )
                                                    "
                                                    oninput="value=value.replace(/^0[0-9]|[^\d.]/g,'')"
                                                >
                                                </el-input>
                                                <span
                                                    v-if="
                                                        scope.row.type ===
                                                        'span'
                                                    "
                                                    >{{
                                                        scope.row.input[index]
                                                            | num45Filter
                                                    }}</span
                                                >
                                            </template>
                                        </el-table-column>
                                    </el-table>
                                </el-row>
                                <div style="margin: 30px 5px">
                                    小计：{{
                                        calculateTabTotal('assets')
                                            | num45Filter
                                    }}
                                </div>
                            </el-tab-pane>
                            <el-tab-pane label="无形资产购买">
                                <el-row>
                                    <el-table
                                        :data="form.immaterial"
                                        border
                                        style="width: 100%"
                                    >
                                        <el-table-column
                                            label="投入项"
                                            width="230"
                                        >
                                            <template slot-scope="scope">
                                                <span>{{
                                                    scope.row.title
                                                }}</span>
                                            </template>
                                        </el-table-column>
                                        <el-table-column
                                            label="合计"
                                            width="100"
                                        >
                                            <template slot-scope="scope">
                                                <span>{{
                                                    calculateSummary(scope.row)
                                                        | num45Filter
                                                }}</span>
                                            </template>
                                        </el-table-column>
                                        <el-table-column
                                            :key="index"
                                            v-for="(p, index) in form.allMonths"
                                            :label="p"
                                            width="100"
                                        >
                                            <template slot-scope="scope">
                                                <el-input
                                                    v-if="
                                                        scope.row.type ===
                                                        'input'
                                                    "
                                                    size="mini"
                                                    :disabled="!canEdit"
                                                    placeholder=""
                                                    v-model="
                                                        scope.row.input[index]
                                                    "
                                                    @input="
                                                        calculateQuotation(
                                                            scope.row,
                                                            index,
                                                            scope.$index
                                                        )
                                                    "
                                                    oninput="value=value.replace(/^0[0-9]|[^\d.]/g,'')"
                                                >
                                                </el-input>
                                                <span
                                                    v-if="
                                                        scope.row.type ===
                                                        'span'
                                                    "
                                                    >{{
                                                        scope.row.input[index]
                                                            | num45Filter
                                                    }}</span
                                                >
                                            </template>
                                        </el-table-column>
                                    </el-table>
                                </el-row>
                                <div style="margin: 30px 5px">
                                    小计：{{
                                        calculateTabTotal('immaterial')
                                            | num45Filter
                                    }}
                                </div>
                            </el-tab-pane>
                        </el-tabs>
                    </div>
                </el-tab-pane>
                <el-tab-pane label="收入拆分">
                    <el-button
                        type="primary"
                        class="btn-add"
                        size="medium"
                        icon="el-icon-plus"
                        @click="addIncomeDistributionRow()"
                        v-if="canEdit"
                        >增加
                    </el-button>
                    <el-table
                        :data="form.incomeDistribution"
                        border
                        stripe
                        style="width: 100%"
                    >
                        <el-table-column width="80">
                            <template slot-scope="scope">
                                <el-button
                                    v-if="!scope.row.total && canEdit"
                                    icon="el-icon-delete"
                                    type="danger"
                                    size="mini"
                                    :disabled="scope.row.canDelete === false"
                                    @click="
                                        removeIncomeDistributionRow(scope.row)
                                    "
                                >
                                </el-button>
                            </template>
                        </el-table-column>
                        <el-table-column label="实施部门" width="250">
                            <template slot-scope="scope">
                                <el-autocomplete
                                    class="inline-input"
                                    size="mini"
                                    :disabled="
                                        scope.row.canDelete === false ||
                                        !canEdit
                                    "
                                    v-model="scope.row.implement_department"
                                    :fetch-suggestions="querySearchDepartment"
                                    placeholder="请输入事业部名或拼音"
                                    clearable
                                    :trigger-on-focus="false"
                                    @change="
                                        implement_department_change(scope.row)
                                    "
                                    @select="
                                        (val) => {
                                            handleSelectImplementDepartmentDistribution(
                                                val,
                                                scope.row
                                            );
                                        }
                                    "
                                ></el-autocomplete>
                            </template>
                        </el-table-column>
                        <el-table-column label="收入比例" width="150">
                            <template slot-scope="scope">
                                <el-input
                                    size="mini"
                                    :disabled="!canEdit"
                                    placeholder=""
                                    v-model="scope.row.percentage"
                                    oninput="value=value.replace(/^0[0-9]|[^\d.]/g,'')"
                                    @change="calculateTotalManMonth"
                                >
                                    <template slot="append">% </template>
                                </el-input>
                            </template>
                        </el-table-column>
                        <el-table-column
                            label="实施部门收入(人民币)"
                            width="200"
                            ><template slot-scope="scope">
                                <span>{{
                                    scope.row.income | num45Filter
                                }}</span></template
                            >
                        </el-table-column>
                        <el-table-column
                            label="历史人力成本+折旧摊销(人民币)"
                            width="250"
                            v-if="
                                requestType === 1 && form.enableSubProjectName
                            "
                        >
                            <template slot-scope="scope">
                                <span
                                    v-if="
                                        form.business_department !== '' &&
                                        scope.row.implement_department ===
                                            form.business_department
                                    "
                                ></span>
                                <span v-else
                                    ><el-input
                                        :disabled="!canEdit"
                                        oninput="value=value.replace(/^0[0-9]|[^\d.]/g,'')"
                                        v-model="scope.row.history_cost"
                                        @change="historyCost()"
                                    ></el-input
                                ></span>
                            </template>
                        </el-table-column>
                        <el-table-column
                            label="预计人力成本+折旧摊销(人民币)"
                            width="250"
                            v-if="form.enableSubProjectName"
                        >
                            <template slot-scope="scope">
                                <span
                                    v-if="
                                        form.business_department !== '' &&
                                        scope.row.implement_department ===
                                            form.business_department
                                    "
                                ></span>
                                <span v-else>
                                    {{ scope.row.cost | num45Filter }}
                                </span>
                            </template>
                        </el-table-column>
                        <el-table-column
                            label="实施部门预计成本（人民币）"
                            width="250"
                            v-if="form.enableSubProjectName"
                        >
                            <template slot-scope="scope">
                                <span
                                    v-if="
                                        form.business_department !== '' &&
                                        scope.row.implement_department ===
                                            form.business_department
                                    "
                                ></span>
                                <span v-else>{{
                                    calcSum([
                                        parseFloat(scope.row.cost || '0'),
                                        parseFloat(
                                            scope.row.history_cost || '0'
                                        ),
                                    ])
                                }}</span>
                            </template>
                        </el-table-column>
                        <el-table-column
                            v-if="form.enableSubProjectName"
                            label="Sub项目名称"
                            width="250"
                        >
                            <template slot-scope="scope">
                                <span>{{ scope.row.sub_project_name }}</span>
                                <el-tag
                                    size="mini"
                                    style="type"
                                    v-if="scope.row.sub_project_id === null"
                                    >new</el-tag
                                >
                            </template>
                        </el-table-column>
                        <el-table-column
                            v-if="form.enableSubProjectName"
                            label="工时管理员"
                            width="250"
                        >
                            <template slot-scope="scope">
                                <span
                                    v-if="
                                        form.business_department !== '' &&
                                        scope.row.implement_department ===
                                            form.business_department
                                    "
                                    >{{ form.project_manager }}</span
                                >
                                <el-autocomplete
                                    class="inline-input"
                                    v-model="scope.row.manager"
                                    :disabled="
                                        scope.row.canDelete === false ||
                                        !canEdit
                                    "
                                    placeholder="请输入姓名或拼音"
                                    :fetch-suggestions="querySearchAsync"
                                    highlight-first-item
                                    v-else
                                    @select="
                                        (val) => {
                                            handleSelectManagerDistribution(
                                                val,
                                                scope.row
                                            );
                                        }
                                    "
                                    @change="
                                        clearSelectManagerDistribution(
                                            scope.row
                                        )
                                    "
                                >
                                    <template slot-scope="{ item }">
                                        <div class="name">
                                            {{ item.value }}
                                            {{ item.ldap }}
                                        </div>
                                    </template>
                                </el-autocomplete>
                            </template>
                        </el-table-column>
                    </el-table>
                    <div style="margin-top: 20px">
                        总比例：<span
                            v-if="sumPercentage() != 100"
                            style="color: red"
                            >{{ sumPercentage() | num45Filter }}%</span
                        >
                        <span v-if="sumPercentage() == 100"
                            >{{ sumPercentage() | num45Filter }}%</span
                        >
                        <span
                            v-if="sumPercentage() != 100"
                            style="color: red; font-size: 14px"
                        >
                            (总比例必须为100%)</span
                        >
                    </div>
                </el-tab-pane>
                <el-tab-pane label="自研量产出货">
                    <el-form ref="form" :model="form" label-width="80px">
                        <el-row>
                            <el-col :span="8">
                                <el-form-item label="税率">
                                    <el-input
                                        placeholder="国内13%, 国外0%"
                                        :disabled="!canEdit"
                                        oninput="value=value.replace(/^0[0-9]|[^\d.]/g,'')"
                                        v-model="form.taxRate"
                                        @input="hardwareProductsValue()"
                                    >
                                        <template slot="append">%</template>
                                    </el-input>
                                </el-form-item>
                            </el-col>
                            <el-table
                                :data="form.hardwareProducts"
                                border
                                style="width: 100%"
                            >
                                <el-table-column
                                    label=""
                                    width="250"
                                    prop="title"
                                >
                                </el-table-column>
                                <el-table-column label="" width="150">
                                    <template slot-scope="scope">
                                        <span v-if="
                                            scope.row.field === 'batch_production_income'
                                        ">
                                            {{
                                                calculateSummary(
                                                    form.hardwareProducts[4]
                                                ) + estIncomeRaw | num45Filter
                                            }}
                                        </span>
                                        <span v-if="
                                            scope.row.field === 'batch_production_income_rmb'
                                        ">
                                            {{
                                                calculateSummary(
                                                    form.hardwareProducts[5]
                                                ) + (estIncomeRaw * form.currency) | num45Filter
                                            }}
                                        </span>
                                        <span v-if="
                                            scope.row.field === 'batch_production_investment_rmb'
                                        ">
                                            {{
                                                estCost + 
                                                calculateSummary(
                                                    form.hardwareProducts[3]
                                                )
                                                | num45Filter
                                            }}
                                        </span>
                                        <span v-if="
                                            scope.row.field ==='batch_production_benefit'
                                        ">
                                            {{
                                                (
                                                    calculateSummary(form.hardwareProducts[5]) + 
                                                    (estIncomeRaw * form.currency)
                                                )
                                                - (
                                                    estCost + 
                                                    calculateSummary(form.hardwareProducts[3]) 
                                                ) | num45Filter
                                            }}
                                        </span>
                                        <span v-if="
                                            scope.row.field ==='batch_production_interest_rate'
                                        ">
                                            {{
                                                Math.round(
                                                    (calculateSummary(
                                                        form.hardwareProducts[5]
                                                    ) + (estIncomeRaw * form.currency)) === 0 ? 0 : 
                                                    (( 
                                                       (
                                                            calculateSummary(form.hardwareProducts[5]) + 
                                                            (estIncomeRaw * form.currency)
                                                        )
                                                        - (
                                                            estCost + 
                                                            calculateSummary(form.hardwareProducts[3]) 
                                                        )
                                                    ) / (
                                                        calculateSummary(
                                                            form.hardwareProducts[5]
                                                        ) + (estIncomeRaw * form.currency)
                                                    )) *100 )
                                            }}%
                                        </span>
                                        <span v-if="
                                            scope.row.field === 'batch_production_interest_rate_comprehensive'
                                        ">
                                            {{
                                                Math.round(
                                                    (calculateSummary(form.hardwareProducts[5]) + 
                                                    (estIncomeRaw * form.currency)) == 0 ? 0 : 
                                                    ((
                                                        (
                                                            calculateSummary(form.hardwareProducts[5]) + 
                                                            (estIncomeRaw * form.currency)
                                                        )
                                                        - (
                                                            estCost + 
                                                            calculateSummary(form.hardwareProducts[3]) 
                                                        )       
                                                    ) / (
                                                            (
                                                                calculateSummary(form.hardwareProducts[5]) + 
                                                                (estIncomeRaw * form.currency)
                                                            )
                                                            - (
                                                                calculateSummary(form.hardwareProducts[3]) 
                                                            ) 
                                                        )
                                                    ) *100 )
                                            }}%
                                        </span>
                                    </template>
                                </el-table-column>
                                <el-table-column label="合计" width="100">
                                        <template slot-scope="scope">
                                            <span v-if="
                                                scope.row.type == 'input'
                                            ">
                                                {{
                                                    calculateSummary(
                                                        scope.row
                                                    )  | num45Filter
                                                }}
                                            </span>
                                            <span v-if="
                                                scope.row.field == 'max_possible_cost'
                                            ">
                                                {{
                                                    calculateSummary(
                                                        form.hardwareProducts[3]
                                                    )  | num45Filter
                                                }}
                                            </span>
                                            <span v-if="
                                                scope.row.field == 'max_possible_income_raw'
                                            ">
                                                {{
                                                    calculateSummary(
                                                        form.hardwareProducts[4]
                                                    )  | num45Filter
                                                }}
                                            </span>
                                            <span v-if="
                                                scope.row.field == 'max_possible_income_rmb'
                                            ">
                                                {{
                                                    calculateSummary(
                                                        form.hardwareProducts[5]
                                                    )  | num45Filter
                                                }}
                                            </span>
                                        </template>
                                </el-table-column>
                                <el-table-column
                                    :key="index"
                                    v-for="(p, index) in form.allMonths"
                                    :label="p"
                                    width="120"
                                >
                                    <template slot-scope="scope">
                                        <el-input
                                            v-if="scope.row.type === 'input'"
                                            size="mini"
                                            :disabled="!canEdit"
                                            placeholder=""
                                            oninput="value=value.replace(/^0[0-9]|[^\d.]/g,'')"
                                            v-model="scope.row.input[index]"
                                            @input="hardwareProductsValue()"
                                        >
                                        </el-input>
                                        <span
                                            v-if="
                                                scope.row.field ===
                                                'max_possible_cost'
                                            "
                                        >
                                            {{
                                                ((form.hardwareProducts[2]
                                                    .input[index] *
                                                    form.hardwareProducts[0]
                                                        .input[index]) /
                                                    (1 + form.taxRate / 100))
                                                    | num45Filter
                                            }}
                                        </span>
                                        <span
                                            v-if="
                                                scope.row.field ===
                                                'max_possible_income_raw'
                                            "
                                        >
                                            {{
                                                ((form.hardwareProducts[2]
                                                    .input[index] *
                                                    form.hardwareProducts[1]
                                                        .input[index]) /
                                                    (1 + form.taxRate / 100))
                                                    | num45Filter
                                            }}
                                        </span>
                                        <span
                                            v-if="
                                                scope.row.field ===
                                                'max_possible_income_rmb'
                                            "
                                        >
                                            {{
                                                ((form.hardwareProducts[2]
                                                    .input[index] *
                                                    form.hardwareProducts[1]
                                                        .input[index] *
                                                    form.currency) /
                                                    (1 + form.taxRate / 100))
                                                    | num45Filter
                                            }}
                                        </span>
                                    </template>
                                </el-table-column>
                            </el-table>
                        </el-row>
                    </el-form>
                </el-tab-pane>
                <el-tab-pane label="合同中约定里程碑节点和项目阶段点计划">
                    <el-button
                        type="primary"
                        class="btn-add"
                        size="medium"
                        icon="el-icon-plus"
                        @click="addStagePlanRow"
                        v-if="canEdit"
                        >增加
                    </el-button>
                    <el-table
                        :data="form.stagePlans"
                        border
                        style="width: 100%"
                    >
                        <el-table-column width="80">
                            <template slot-scope="scope">
                                <el-button
                                    v-if="!scope.row.total"
                                    icon="el-icon-delete"
                                    type="danger"
                                    :disabled="!canEdit"
                                    size="mini"
                                    @click="removeStagePlan(scope.row)"
                                ></el-button>
                            </template>
                        </el-table-column>
                        <el-table-column
                            :key="v.field"
                            v-for="v in form.stagePlanColumns"
                            :prop="v.field"
                            :label="v.title"
                            :width="v.width"
                        >
                            <template slot-scope="scope">
                                <el-input
                                    v-if="
                                        v.type == 'input' &&
                                        v.field == 'milestone' &&
                                        !scope.row.total
                                    "
                                    size="mini"
                                    :disabled="!canEdit"
                                    placeholder=""
                                    v-model="scope.row[v.field]"
                                >
                                </el-input>
                                <el-input
                                    v-if="
                                        v.type == 'input' &&
                                        v.field != 'milestone' &&
                                        !scope.row.total
                                    "
                                    size="mini"
                                    :disabled="!canEdit"
                                    placeholder=""
                                    oninput="value=value.replace(/^0[0-9]|[^\d.]/g,'')"
                                    v-model="scope.row[v.field]"
                                >
                                </el-input>
                                <el-input
                                    v-if="
                                        v.type == 'textarea' && !scope.row.total
                                    "
                                    type="textarea"
                                    size="mini"
                                    :disabled="!canEdit"
                                    placeholder=""
                                    v-model="scope.row[v.field]"
                                >
                                </el-input>
                                <el-select
                                    v-if="
                                        v.type == 'select' && !scope.row.total
                                    "
                                    :disabled="!canEdit"
                                    v-model="scope.row[v.field]"
                                    placeholder="请选择"
                                >
                                    <el-option
                                        v-for="item in v.options"
                                        :key="item.value"
                                        :label="item.label"
                                        :value="item.value"
                                    >
                                    </el-option>
                                </el-select>
                                <el-date-picker
                                    v-if="v.type == 'date' && !scope.row.total"
                                    type="date"
                                    placeholder="选择日期"
                                    :disabled="!canEdit"
                                    style="width: 100%"
                                    value-format="yyyy-MM-dd"
                                    v-model="scope.row[v.field]"
                                >
                                </el-date-picker>
                                <span
                                    v-if="
                                        scope.row.total &&
                                        (v.field == 'amount' ||
                                            v.field == 'est_input_man_month' ||
                                            v.field == 'est_input_cost')
                                    "
                                    >{{
                                        sumStageTotal(v.field) | num45Filter
                                    }}</span
                                >
                            </template>
                        </el-table-column>
                    </el-table>
                </el-tab-pane>
                <el-tab-pane label="特批事项">
                    <el-upload
                        ref="uploadSpecialApproval"
                        v-if="canEdit"
                        :action="upload_api"
                        :file-list="form.special_approval_attachments"
                        :on-success="uploadSpecialApprovalSuccess"
                        :data="specialApprovalAttachmentData"
                        :auto-upload="true"
                        style="margin-bottom: 25px"
                        :show-file-list="false"
                        drag
                        multiple
                    >
                        <i class="el-icon-upload"></i>
                        <div class="el-upload__text">
                            将文件拖到此处，或<em>点击上传</em>
                        </div>
                    </el-upload>
                    <el-table :data="form.special_approval_list">
                        <el-table-column label="文件名">
                            <template slot-scope="scope">
                                <span>{{ scope.row.fileName }}</span>
                            </template>
                        </el-table-column>
                        <el-table-column label="操作">
                            <template slot-scope="scope">
                                <el-button
                                    size="mini"
                                    icon="el-icon-download"
                                    @click="
                                        handleDownloadAttachment(
                                            scope.$index,
                                            scope.row
                                        )
                                    "
                                    >下载</el-button
                                >
                                <el-button
                                    size="mini"
                                    type="danger"
                                    icon="el-icon-delete"
                                    v-if="canEdit"
                                    @click="
                                        handleSpecialApprovalDeleteAttachment(
                                            scope.$index,
                                            scope.row
                                        )
                                    "
                                    >删除</el-button
                                >
                            </template>
                        </el-table-column>
                    </el-table>
                    <p>
                        <span style="color: red"
                            >当预计毛利率＜底线利润率,
                            请将利润率特批申请审批通过的内容（包括原因、承诺改善事项等）记录在OA上，并上传特批申请审批通过的邮件作为附件。</span
                        >
                    </p>
                    <p>
                        <span style="color: red"
                            >当预计毛利率≥底线利润率,
                            无利润率特批事项，请填“无”。</span
                        >
                    </p>
                    <div style="height: 54px">
                        <div style="width: 15%; float: left; line-height: 30px">
                            <span style="color: #666"
                                >利润率特批申请审批通过的内容</span
                            >
                        </div>
                        <div style="width: 85%; float: left">
                            <el-input
                                type="textarea"
                                :disabled="!canEdit"
                                style="margin-top: 0px"
                                v-model="form.special_approval"
                                maxlength="2000"
                                show-word-limit
                            ></el-input>
                        </div>
                    </div>
                </el-tab-pane>
                <el-tab-pane label="立项资料附件上传">
                    <el-upload
                        ref="upload"
                        v-if="canEdit"
                        :action="upload_api"
                        :file-list="form.attachments"
                        :on-success="uploadSuccess"
                        :data="attachmentData"
                        :auto-upload="true"
                        style="margin-bottom: 25px"
                        :show-file-list="false"
                        drag
                        multiple
                    >
                        <i class="el-icon-upload"></i>
                        <div class="el-upload__text">
                            将文件拖到此处，或<em>点击上传</em>
                        </div>
                    </el-upload>
                    <el-button
                        size="mini"
                        icon="el-icon-download"
                        v-if="form.file_list.length > 1"
                        @click="
                            handleDownloadAttachmentAll()
                        "
                        >批量下载</el-button
                    >
                    <el-table :data="form.file_list" @selection-change="handleSelectionChange">
                        <el-table-column
                            v-if="form.file_list.length > 1"
                            type="selection"
                            width="55">
                        </el-table-column>
                        <el-table-column label="文件名">
                            <template slot-scope="scope">
                                <span>{{ scope.row.fileName }}</span>
                            </template>
                        </el-table-column>
                        <el-table-column label="操作">
                            <template slot-scope="scope">
                                <el-button
                                    size="mini"
                                    icon="el-icon-download"
                                    @click="
                                        handleDownloadAttachment(
                                            scope.$index,
                                            scope.row
                                        )
                                    "
                                    >下载</el-button
                                >
                                <el-button
                                    size="mini"
                                    type="danger"
                                    icon="el-icon-delete"
                                    v-if="canEdit"
                                    @click="
                                        handleDeleteAttachment(
                                            scope.$index,
                                            scope.row
                                        )
                                    "
                                    >删除</el-button
                                >
                            </template>
                        </el-table-column>
                    </el-table>
                </el-tab-pane>
                <!--        <el-tab-pane label="历史"></el-tab-pane>-->
                <!--        <el-tab-pane label="debug">{{ form.projectIncome }}</el-tab-pane>-->
            </el-tabs>
        </div>
        <div class="request-submit">
            <div>
                <div class="cost-about">
                    <div class="item-cell cost-price">
                        <div>
                            <div class="label-item">
                                <div>
                                    <label class="label"
                                        >预计总收入(原币)</label
                                    >
                                    <div class="detail">
                                        <span class="price">{{
                                            estIncomeRaw | num45Filter
                                        }}</span>
                                        <span
                                            v-if="oldCalculated"
                                            :style="
                                                estIncomeRaw >=
                                                    oldCalculated.est_income_raw
                                                    ? 'color: green'
                                                    : 'color: red'
                                            "
                                            >({{
                                                estIncomeRaw >=
                                                    oldCalculated.est_income_raw
                                                    ? '+'
                                                    : ''
                                            }}{{
                                                (estIncomeRaw -
                                                    oldCalculated.est_income_raw)
                                                    | num45Filter
                                            }})</span
                                        >
                                    </div>
                                </div>
                            </div>
                            <div class="label-item">
                                <div>
                                    <label class="label"
                                        >预计总收入(人民币)</label
                                    >
                                    <div class="detail">
                                        <span class="price">{{
                                            (estIncomeRaw * form.currency)
                                                | num45Filter
                                        }}</span>
                                        <span
                                            v-if="oldCalculated"
                                            :style="
                                                estIncomeRaw * form.currency >=
                                                oldCalculated.est_income
                                                    ? 'color: green'
                                                    : 'color: red'
                                            "
                                            >({{
                                                estIncomeRaw * form.currency >=
                                                oldCalculated.est_income
                                                    ? '+'
                                                    : ''
                                            }}{{
                                                (estIncomeRaw * form.currency -
                                                    oldCalculated.est_income)
                                                    | num45Filter
                                            }})</span
                                        >
                                    </div>
                                </div>
                            </div>
                            <div class="label-item">
                                <div>
                                    <label class="label"
                                        >预计总投入(人民币)</label
                                    >
                                    <div class="detail">
                                        <span class="price">{{
                                            estCost | num45Filter
                                        }}</span>
                                        <span
                                            v-if="oldCalculated"
                                            :style="
                                                estCost >=
                                                oldCalculated.est_cost
                                                    ? 'color: green'
                                                    : 'color: red'
                                            "
                                            >({{
                                                estCost >=
                                                oldCalculated.est_cost
                                                    ? '+'
                                                    : ''
                                            }}{{
                                                (estCost -
                                                    oldCalculated.est_cost)
                                                    | num45Filter
                                            }})</span
                                        >
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="cost-about">
                    <div class="item-cell cost-price">
                        <div>
                            <div class="label-item">
                                <div>
                                    <label class="label"
                                        >预计毛利(人民币)</label
                                    >
                                    <div class="detail">
                                        <span class="price">{{
                                            (estIncomeRaw * form.currency -
                                                estCost)
                                                | num45Filter
                                        }}</span>
                                        <span
                                            v-if="oldCalculated"
                                            :style="
                                                estIncomeRaw * form.currency -
                                                    estCost >=
                                                oldCalculated.profit
                                                    ? 'color: green'
                                                    : 'color: red'
                                            "
                                            >({{
                                                estIncomeRaw * form.currency -
                                                    estCost >=
                                                oldCalculated.profit
                                                    ? '+'
                                                    : ''
                                            }}{{
                                                (estIncomeRaw * form.currency -
                                                    estCost) -
                                                    oldCalculated.profit
                                                    | num45Filter
                                            }})</span
                                        >
                                    </div>
                                </div>
                            </div>
                            <div class="label-item">
                                <div>
                                    <label class="label">预计毛利率</label>
                                    <div class="detail">
                                        <span class="price"
                                            >{{
                                                Math.round(
                                                    estIncome
                                                        ? ((estIncomeRaw *
                                                              form.currency -
                                                              estCost) *
                                                              100) /
                                                              (estIncomeRaw *
                                                                  form.currency)
                                                        : 0 
                                                )
                                            }}%</span
                                        >
                                        <span
                                            v-if="oldCalculated"
                                            :style="
                                                Math.round(
                                                    (estIncome
                                                        ? ((estIncomeRaw *
                                                              form.currency -
                                                              estCost) *
                                                              100) /
                                                          (estIncomeRaw *
                                                              form.currency)
                                                        : 0) ) >=
                                                        Math.round(
                                                            oldCalculated.profit_rate 
                                                        )
                                                    ? 'color: green'
                                                    : 'color: red'
                                            "
                                        >
                                            ({{
                                                Math.round(
                                                    (estIncome
                                                        ? ((estIncomeRaw *
                                                              form.currency -
                                                              estCost) *
                                                              100) /
                                                          (estIncomeRaw *
                                                              form.currency)
                                                        : 0 ) | num45Filter) >=
                                                        Math.round(
                                                            oldCalculated.profit_rate 
                                                    )
                                                    ? '+'
                                                    : ''
                                            }}{{
                                                Math.round(
                                                    estIncome
                                                        ? ((estIncomeRaw *
                                                              form.currency -
                                                              estCost) *
                                                              100) /
                                                              (estIncomeRaw *
                                                                  form.currency)
                                                        : 0 
                                                ) - 
                                                    Math.round(
                                                        oldCalculated.profit_rate 
                                                )
                                            }}%)
                                        </span>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="cost-about">
                    <div class="item-cell cost-price">
                        <div>
                            <div class="label-item">
                                <div>
                                    <label class="label"
                                        >预计投入总人月数</label
                                    >
                                    <div class="detail">
                                        <span class="price">{{
                                            totalManMonth | num45Filter
                                        }}</span>
                                        <span
                                            v-if="oldCalculated"
                                            :style="
                                                totalManMonth >=
                                                oldCalculated.total_man_month
                                                    ? 'color: green'
                                                    : 'color: red'
                                            "
                                            >({{
                                                totalManMonth >=
                                                oldCalculated.total_man_month
                                                    ? '+'
                                                    : ''
                                            }}{{
                                                (totalManMonth -
                                                    oldCalculated.total_man_month)
                                                    | num45Filter
                                            }})</span
                                        >
                                    </div>
                                </div>
                            </div>
                            <div class="label-item">
                                <div>
                                    <label class="label"
                                        >人均收入(人民币)</label
                                    >
                                    <div class="detail">
                                        <span class="price">{{
                                            (totalManMonth == 0
                                                ? 0
                                                : (estIncomeRaw *
                                                      form.currency) /
                                                  totalManMonth) | num45Filter
                                        }}</span>
                                        <span
                                            v-if="oldCalculated"
                                            :style="
                                                (totalManMonth == 0
                                                    ? 0
                                                    : (estIncomeRaw *
                                                          form.currency) /
                                                      totalManMonth) >=
                                                    (oldCalculated.total_man_month == 0 
                                                        ? 0:
                                                        oldCalculated.est_income /
                                                            oldCalculated.total_man_month)
                                                    ? 'color: green'
                                                    : 'color: red'
                                            "
                                        >
                                            ({{
                                                (totalManMonth == 0
                                                    ? 0
                                                    : (estIncomeRaw *
                                                          form.currency) /
                                                      totalManMonth) >=
                                                    (oldCalculated.total_man_month == 0 
                                                        ? 0:
                                                        oldCalculated.est_income /
                                                            oldCalculated.total_man_month)
                                                    ? '+'
                                                    : ''
                                            }}{{
                                                (totalManMonth == 0
                                                    ? 0
                                                    : (estIncomeRaw *
                                                          form.currency) /
                                                      totalManMonth) -
                                                    (oldCalculated.total_man_month == 0 
                                                        ? 0:
                                                        oldCalculated.est_income /
                                                            oldCalculated.total_man_month)
                                                    | num45Filter
                                            }})
                                        </span>
                                    </div>
                                </div>
                            </div>
                            <div class="label-item">
                                <div>
                                    <label class="label"
                                        >人均成本(人民币)</label
                                    >
                                    <div class="detail">
                                        <span class="price">{{
                                            (totalManMonth == 0
                                                ? 0
                                                : estCost / totalManMonth)
                                                | num45Filter
                                        }}</span>
                                        <span
                                            v-if="oldCalculated"
                                            :style="
                                                (totalManMonth == 0
                                                    ? 0
                                                    : estCost / totalManMonth) >=
                                                    (oldCalculated.total_man_month == 0
                                                    ? 0
                                                        : oldCalculated.avg_cost_RMB)
                                                    ? 'color: green'
                                                    : 'color: red'
                                            "
                                        >
                                            ({{
                                                (totalManMonth == 0
                                                    ? 0
                                                    : estCost / totalManMonth) >=
                                                    (oldCalculated.total_man_month == 0
                                                    ? 0
                                                        :  oldCalculated.avg_cost_RMB)
                                                    ? '+'
                                                    : ''
                                            }}{{
                                                 (totalManMonth == 0
                                                    ? 0
                                                    : estCost / totalManMonth) -
                                                    (oldCalculated.total_man_month == 0
                                                    ? 0
                                                        : oldCalculated.avg_cost_RMB)
                                                    | num45Filter
                                            }})
                                        </span>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</template>

<script>
import FileSaver from 'file-saver';
import XLSX from 'xlsx';
import pinyin from 'pinyin';
import http from '@/views/sys/axios';
import lodash from 'lodash';
import { getName } from '@/utils/auth';
import { changeProject, submitProject } from '@/views/project_request/workflow';
import {
    getProjectPeriods,
    initHistoryLabourInput,
    sumHistoryTotalManMonth,
    sumTotalManMonthList,
    getBusinessType,
    getProductionCategory,
} from '@/views/project_request/data';
import {
    canEditForm,
    checkImplDeptManager,
    checkStagePoint,
} from '@/views/project_request/check';
import { baseRules } from '@/views/project_request/rules';
import { constants } from '@/views/project_request/constants';
import { distributionCalc } from '@/views/project_request/calculation';
import { getDepartmentById } from '@/views/project_request/fetch';

export default {
    name: 'ProjectRequest',
    props: {
        form: Object,
        mode: String,
        canEdit: Boolean,
    },
    data() {
        let validatePercentage25 = (rule, value, callback) => {
            if (parseFloat(value) < 25) {
                return callback(new Error('立项事业部需至少保留总收入的25%'));
            }
        };
        return {
            productList: [],
            enableSubProjectName: true,
            version: '',
            oldProjectPeriod: '',
            pastMonths: [],
            nextMonths: [],
            allMonths: [],
            EditorValue: [],
            editorState: '',
            editorState_id: '',
            editorState_ldap:'',
            showName: false,
            lokAdd: false,
            addEditorShow: false,
            formLink: `${process.env.VUE_APP_KANBAN_HOST}/#/project_request/view/${this.$route.params.id}`,
            // project_manager_id: '',
            nodeEnv: process.env.NODE_ENV,
            labourCostDetails: {},
            requestType: 0,
            errMessage: null,
            baseRules: baseRules,
            loading: false,
            BACKEND_API: process.env.VUE_APP_PROJECT_REQUEST_HOST,
            upload_api: `${process.env.VUE_APP_PROJECT_REQUEST_HOST}/api/base/workflow/upload_attachment`,
            username: '',
            projectIcon: 'el-icon-more',
            project_name_save: '',
            profit: 0,
            profit_rate: 0,
            ldap: getName(),
            state: '',
            timeout: null,
            totalManMonth: 0,
            avgCostRMB: 0,
            software_platforms: [],
            hardware_platforms: [],
            corporations: [],
            departments: [],
            roles: [],
            customers: [],
            selectedManPowerRow: null,
            activeIndex: '1',
            projectPeriod: 0,
            employees: [],
            application_types: [
                { label: '立项', value: 0 },
                { label: '变更', value: 1 },
            ],
            incomeCheckMethods: constants.incomeCheckMethods,
            productionOptions: constants.productionOptions,
            businessOptions: constants.businessOptions,
            exchangeRate: constants.exchangeRate,
            estCost: 0,
            estIncome: 0,
            estIncomeRaw: 0,
            rules: {
                percentage25: [
                    { validator: validatePercentage25, trigger: 'blur' },
                ],
            },
            oldForm: null,
            oldCalculated: null,
            archivedProjects: [],
            // project_manager_name: '',
            messagePromise: Promise.resolve(),
            financeTableExcDialog: false,
            outExc_newDialog: false,
            outExc_oldDialog: false,
            outsourceExc_Dialog: false,
            startCell: -1,
            startCell_old: -1,
            startCell_outside: -1,
            startCell_income:-1,
            endCell: -1,
            endCell_old: -1,
            endCell_outside: -1,
            endCell_income:-1,
            numShow: false,
            tabName: '',
            fileList: [],
            lastStartTime:'',
            lastEndTime:'',
        };
    },
    watch: {
        form: {
            handler(newVal, oldVal) {
                if (this.canEdit) {
                    this.saveForm();
                }
            },
            deep: true,
        },
    },
    filters: {
        numFilter(value) {
            let tempVal = parseFloat(value || 0).toFixed(3);
            let realVal = tempVal.substring(0, tempVal.length - 1);
            return realVal;
        },
        num45Filter(amount, decimalCount = 2, decimal = '.', thousands = ',') {
            try {
                decimalCount = Math.abs(decimalCount);
                decimalCount = isNaN(decimalCount) ? 2 : decimalCount;

                const negativeSign = amount < 0 ? '-' : '';
                let tempVal = Math.pow(10, 2);
                let i = parseInt(
                    (amount = Math.abs(
                        Number(Math.round(amount * tempVal) / tempVal) || 0
                    ).toFixed(decimalCount))
                ).toString();
                let j = i.length > 3 ? i.length % 3 : 0;

                return (
                    negativeSign +
                    (j ? i.substr(0, j) + thousands : '') +
                    i.substr(j).replace(/(\d{3})(?=\d)/g, '$1' + thousands) +
                    (decimalCount
                        ? decimal +
                          Math.abs(amount - i)
                              .toFixed(decimalCount)
                              .slice(2)
                        : '')
                );
            } catch (e) {
                console.log(e);
            }
        },
    },
    computed: {
        attachmentData: function () {
            return {
                form_id: this.form.form_id,
            };
        },
        specialApprovalAttachmentData: function () {
            return {
                form_id: this.form.form_id,
            };
        },
    },
    created() {
        this.pre_project_name_value = _.debounce(this.preProjectNameAsync, 400);
        this.getname();
        if (this.mode === 'create') {
            this.getUserInfo().then((res) => {
                this.form.project_manager = res.data.data[0].name;
                this.form.project_manager_id = res.data.data[0].id;
            });
        }
        if (this.mode === 'edit') {
           
            if(this.requestType === 1){
                this.getUserInfo().then((res) => {
                    this.form.project_manager = res.data.data[0].name;
                    this.form.project_manager_id = res.data.data[0].id;
                });
            }
        }
    },
    mounted() {
        this.productList = this.loadProductList();
        this.customers = this.loadCustomers();
        this.software_platforms = this.loadSoftwarePlatforms();
        this.hardware_platforms = this.loadHardwarePlatforms();
        this.roles = this.loadRoles();
        this.employees = this.loadEmployees();
        this.corporations = this.loadCorporations();
        // this.departments = this.loadDepartments();
        this.estCost = this.calculated ? this.calculated.est_cost : 0;
        this.estIncome = this.calculated ? this.calculated.est_income : 0;
        this.estIncomeRaw = this.calculated
            ? this.calculated.est_income_raw
            : 0;
        this.profit = this.calculated ? this.calculated.profit : 0;
        this.profit_rate = this.calculated ? this.calculated.profit_rate : 0;
        this.totalManMonth = this.calculated
            ? this.calculated.total_man_month
            : 0;
        this.avgCostRMB = this.calculated ? this.calculated.avg_cost_RMB : 0;
        if (this.canEdit) {
            this.project_name_save = this.form.project_name;
        }
        if (this.mode === 'create') {
            this.loadLocalFormData();
        } else if (this.mode === 'edit') {
            this.getProjectValue(this.$route.params.id).then(data=>{
                this.loadFormData(this.$route.params.id,data.project_name)
                this.form.form_id = this.$route.params.id;
            });
        } else if (this.mode === 'view') {
            // load data in view mode
            this.getProjectValue(this.$route.params.id).then(data=>{
                this.loadFormData(this.$route.params.id,data.project_name)
                this.form.form_id = this.$route.params.id;
            });
        } else if (this.mode === 'change') {
            this.form.application_type = 1;
        }
    },
    destroyed() {},
    methods: {
        getProjectValue(id){
            return new Promise((resolve,reject)=>{
                this.$axios
                .get(
                        `${process.env.VUE_APP_PROJECT_REQUEST_HOST}/api/base/project/creater/change?form_id=${id}`
                    ).then(res=>{
                        resolve(res.data.data);
                    }).catch(err=>{
                        reject(err)
                    })
            })
        },
        historyCost(){
            this.form.incomeDistribution.forEach((item,index) =>{
                if(item.history_cost == ""){
                    this.form.incomeDistribution[index].history_cost = 0
                }
            })
        },
        hardwareProductsValue(){
            this.form.hardwareProducts.forEach((item,index) =>{
                this.form.hardwareProducts[3].input[index] =
                    parseFloat(
                        (
                            this.form.hardwareProducts[2].input[index] *
                            this.form.hardwareProducts[0].input[index]
                        ) / (
                            1 + this.form.taxRate / 100
                        )
                    )
                this.form.hardwareProducts[4].input[index] =
                    parseFloat(
                        (
                            this.form.hardwareProducts[2].input[index] *
                            this.form.hardwareProducts[1].input[index]
                        ) / (
                            1 + this.form.taxRate / 100
                        )
                    )
                this.form.hardwareProducts[5].input[index] =
                    parseFloat(
                        (
                            this.form.hardwareProducts[2].input[index] *
                            this.form.hardwareProducts[1].input[index] *
                            this.form.currency
                        ) / (
                            1 + this.form.taxRate / 100
                        )
                    )
            })
            
        },
        getDuration(endDate, startDate) {
            let end = new Date(endDate).getTime();
            let start = new Date(startDate).getTime();
            let duration = (end - start) / (24 * 60 * 60 * 30 * 1000);
            return Math.floor(duration * 10) / 10;
        },
        getDepartmentId(departmentName) {
            return new Promise((resolve, reject) => {
                this.$axios
                    .get(
                        `${this.BACKEND_API}/api/base/department/exist?name=${departmentName}`
                    )
                    .then((response) => {
                        resolve(response.data);
                    })
                    .catch((err) => {
                        console.log(err);
                        resolve({ id: null });
                    });
            });
        },
        getSubProjectId(subProjectName) {
            return new Promise((resolve, reject) => {
                this.$axios
                    .get(
                       `${this.BACKEND_API}/api/base/project/exist?project_name=${subProjectName}`
                    )
                    .then((response) => {
                        resolve(response.data);
                    })
                    .catch((err) => {
                        console.log(err);
                        resolve({ id: null });
                    });
            });
        },
        calcSum(values) {
            return this.num45Filter(lodash.sum(values));
        },
        tableRowIndex({ row, rowIndex }) {
            //把每一行的索引放进row
            row.index = rowIndex; //拿到的索引赋值给row的index,在这个表格中能拿到row的里面都会包含index
            return ''; //className(类名)
        },
        addClass_income({ row, column, rowIndex, columnIndex }){
            if (column.type == 'cell') {
                if (
                    row.sub_module &&
                    row.sub_module[columnIndex - 3] &&
                    row.sub_module[columnIndex - 3].value
                ) {
                    return 'cell-green';
                } else {
                    return '';
                }
            } else {
                return '';
            }
        },
        addClass_old({ row, column, rowIndex, columnIndex }) {
            if (column.type == 'cell') {
                if (
                    row.sub_module &&
                    row.sub_module[columnIndex - 1] &&
                    row.sub_module[columnIndex - 1].value
                ) {
                    return 'cell-green';
                } else {
                    return '';
                }
            } else {
                return '';
            }
        },
        addClass({ row, column, rowIndex, columnIndex }) {
            if (column.type == 'cell') {
                if (
                    row.sub_module &&
                    row.sub_module[columnIndex - 6] &&
                    row.sub_module[columnIndex - 6].value
                ) {
                    return 'cell-green';
                } else {
                    return '';
                }
            } else {
                return '';
            }
        },
        addClass_outside({ row, column, rowIndex, columnIndex }) {
            if (column.type == 'cell') {
                if (
                    row.sub_module &&
                    row.sub_module[columnIndex - 6] &&
                    row.sub_module[columnIndex - 6].value
                ) {
                    return 'cell-green';
                } else {
                    return '';
                }
            } else {
                return '';
            }
        },
        selectCell_income(row, column, cell, event) {
            if (row.isTotal || row.index !== 0 || column.type != 'cell') {
                return false;
            }
            let index = row.index;
            let colIndex = column.index;
            let inputList = [];
            for (let key in row.input) {
                inputList.push({
                    key: key,
                    value: row.input[key],
                });
            }
            let selectList = [];
            if (
                (this.startCell_income < 0 && this.endCell_income < 0) ||
                (this.startCell_income >= 0 && this.endCell_income >= 0)
            ) {
                this.startCell_income = colIndex;
                this.endCell_income = -1;
                inputList.map((v, i) => {
                    if (i == colIndex) {
                        selectList.push({
                            key: v.key,
                            value: true,
                        });
                    } else {
                        selectList.push({
                            key: v.key,
                            value: false,
                        });
                    }
                });
            } else {
                this.endCell_income = colIndex;
                let min =
                    this.startCell_income <= this.endCell_income
                        ? this.startCell_income
                        : this.endCell_income;
                let max =
                    this.startCell_income <= this.endCell_income
                        ? this.endCell_income
                        : this.startCell_income;
                inputList.map((v, i) => {
                    if (i >= min && i <= max) {
                        selectList.push({
                            key: v.key,
                            value: true,
                        });
                    } else {
                        selectList.push({
                            key: v.key,
                            value: false,
                        });
                    }
                });
                this.numShow = true;
                this.open_income(row,index);
            }
            row.sub_module = selectList;
            this.$set(this.form.projectIncome, index, row);
        },
        selectCell_old(row, column, cell, event) {
            if (row.isTotal || row.index === 1 || column.type != 'cell') {
                return false;
            }
            let index = row.index;
            let colIndex = column.index;
            let inputList = [];
            for (let key in row.input) {
                inputList.push({
                    key: key,
                    value: row.input[key],
                });
            }
            let selectList = [];
            if (
                (this.startCell_old < 0 && this.endCell_old < 0) ||
                (this.startCell_old >= 0 && this.endCell_old >= 0)
            ) {
                this.startCell_old = colIndex;
                this.endCell_old = -1;
                inputList.map((v, i) => {
                    if (i == colIndex) {
                        selectList.push({
                            key: v.key,
                            value: true,
                        });
                    } else {
                        selectList.push({
                            key: v.key,
                            value: false,
                        });
                    }
                });
            } else {
                this.endCell_old = colIndex;
                let min =
                    this.startCell_old <= this.endCell_old
                        ? this.startCell_old
                        : this.endCell_old;
                let max =
                    this.startCell_old <= this.endCell_old
                        ? this.endCell_old
                        : this.startCell_old;
                inputList.map((v, i) => {
                    if (i >= min && i <= max) {
                        selectList.push({
                            key: v.key,
                            value: true,
                        });
                    } else {
                        selectList.push({
                            key: v.key,
                            value: false,
                        });
                    }
                });
                this.numShow = true;
                this.open_old();
            }
            row.sub_module = selectList;
            this.$set(this.form.historyManPowerInput, index, row);
        },
        selectCell(row, column, cell, event) {
            if (row.isTotal || column.type != 'cell') {
                return false;
            }
            let index = row.index;
            let colIndex = column.index;
            let inputList = [];
            for (let key in row.input) {
                inputList.push({
                    key: key,
                    value: row.input[key],
                });
            }
            let selectList = [];
            if (
                (this.startCell < 0 && this.endCell < 0) ||
                (this.startCell >= 0 && this.endCell >= 0)
            ) {
                this.startCell = colIndex;
                this.endCell = -1;
                inputList.map((v, i) => {
                    if (i == colIndex) {
                        selectList.push({
                            key: v.key,
                            value: true,
                        });
                    } else {
                        selectList.push({
                            key: v.key,
                            value: false,
                        });
                    }
                });
            } else {
                this.endCell = colIndex;
                let min =
                    this.startCell <= this.endCell
                        ? this.startCell
                        : this.endCell;
                let max =
                    this.startCell <= this.endCell
                        ? this.endCell
                        : this.startCell;
                inputList.map((v, i) => {
                    if (i >= min && i <= max) {
                        selectList.push({
                            key: v.key,
                            value: true,
                        });
                    } else {
                        selectList.push({
                            key: v.key,
                            value: false,
                        });
                    }
                });
                this.numShow = true;
                this.open();
            }
            row.sub_module = selectList;
            this.$set(this.form.manPowerInput, index, row);
        },
        selectCell_outside(row, column, cell, event) {
            if (row.isTotal || column.type != 'cell') {
                return false;
            }
            let index = row.index;
            let colIndex = column.index;
            let inputList = [];
            for (let key in row.input) {
                inputList.push({
                    key: key,
                    value: row.input[key],
                });
            }
            let selectList = [];
            if (
                (this.startCell_outside < 0 && this.endCell_outside < 0) ||
                (this.startCell_outside >= 0 && this.endCell_outside >= 0)
            ) {
                this.startCell_outside = colIndex;
                this.endCell_outside = -1;
                inputList.map((v, i) => {
                    if (i == colIndex) {
                        selectList.push({
                            key: v.key,
                            value: true,
                        });
                    } else {
                        selectList.push({
                            key: v.key,
                            value: false,
                        });
                    }
                });
            } else {
                this.endCell_outside = colIndex;
                let min =
                    this.startCell_outside <= this.endCell_outside
                        ? this.startCell_outside
                        : this.endCell_outside;
                let max =
                    this.startCell_outside <= this.endCell_outside
                        ? this.endCell_outside
                        : this.startCell_outside;
                inputList.map((v, i) => {
                    if (i >= min && i <= max) {
                        selectList.push({
                            key: v.key,
                            value: true,
                        });
                    } else {
                        selectList.push({
                            key: v.key,
                            value: false,
                        });
                    }
                });
                this.numShow = true;
                this.open_outside();
            }
            row.sub_module = selectList;
            this.$set(this.form.manPowerOutSourcingInput, index, row);
        },
        open_income(row , rowIndex) {
            this.$prompt('请输入工数', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                inputPattern: /^(\d+(\.\d+)?)$/,
                inputErrorMessage: '请填写大于0的数',
            })
                .then(({ value }) => {
                    this.addAllManWeek_income(value);
                    this.startCell = -1;
                    this.endCell = -1;
                    this.form.projectIncome.map((item, index) => {
                        if (item.sub_module) {
                            item.sub_module.map((v, i) => {
                                this.$set(item.sub_module, i, {
                                    key: v.key,
                                    value: false,
                                });
                            });
                        }
                        if(item.input){
                            item.input.map((value,index) =>{
                                this.calculateQuotation(row, index , rowIndex);
                            })
                        }
                        this.$set(this.form.projectIncome, index, item);
                    });
                    this.calculateQuotation(row, index, rowIndex);
                })
                .catch(() => {
                    this.startCell = -1;
                    this.endCell = -1;
                    this.form.projectIncome.map((item, index) => {
                        if (item.sub_module) {
                            item.sub_module.map((v, i) => {
                                this.$set(item.sub_module, i, {
                                    key: v.key,
                                    value: false,
                                });
                            });
                        }
                        this.$set(this.form.projectIncome, index, item);
                    });
                });
        },
        open_old() {
            this.$prompt('请输入工数', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                inputPattern: /^(\d+(\.\d+)?)$/,
                inputErrorMessage: '请填写大于0的数',
            })
                .then(({ value }) => {
                    this.addAllManWeek_old(value);
                    this.startCell = -1;
                    this.endCell = -1;
                    this.form.historyManPowerInput.map((item, index) => {
                        if (item.sub_module) {
                            item.sub_module.map((v, i) => {
                                this.$set(item.sub_module, i, {
                                    key: v.key,
                                    value: false,
                                });
                            });
                        }
                        this.$set(this.form.historyManPowerInput, index, item);
                        this.calculateTotalManMonth();
                    });
                })
                .catch(() => {
                    this.startCell = -1;
                    this.endCell = -1;
                    this.form.historyManPowerInput.map((item, index) => {
                        if (item.sub_module) {
                            item.sub_module.map((v, i) => {
                                this.$set(item.sub_module, i, {
                                    key: v.key,
                                    value: false,
                                });
                            });
                        }
                        this.$set(this.form.historyManPowerInput, index, item);
                    });
                });
        },
        open() {
            this.$prompt('请输入工数', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                inputPattern: /^(\d+(\.\d+)?)$/,
                inputErrorMessage: '请填写大于0的数',
            })
                .then(({ value }) => {
                    this.addAllManWeek(value);
                    this.startCell = -1;
                    this.endCell = -1;
                    this.form.manPowerInput.map((item, index) => {
                        if (item.sub_module) {
                            item.sub_module.map((v, i) => {
                                this.$set(item.sub_module, i, {
                                    key: v.key,
                                    value: false,
                                });
                            });
                        }
                        this.$set(this.form.manPowerInput, index, item);
                        this.calculateTotalManMonth();
                    });
                })
                .catch(() => {
                    this.startCell = -1;
                    this.endCell = -1;
                    this.form.manPowerInput.map((item, index) => {
                        if (item.sub_module) {
                            item.sub_module.map((v, i) => {
                                this.$set(item.sub_module, i, {
                                    key: v.key,
                                    value: false,
                                });
                            });
                        }
                        this.$set(this.form.manPowerInput, index, item);
                    });
                });
        },
        open_outside() {
            this.$prompt('请输入工数', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                inputPattern: /^(\d+(\.\d+)?)$/,
                inputErrorMessage: '请填写大于0的数',
            })
                .then(({ value }) => {
                    this.addAllManWeek_outside(value);
                    this.startCell = -1;
                    this.endCell = -1;
                    this.form.manPowerOutSourcingInput.map((item, index) => {
                        if (item.sub_module) {
                            item.sub_module.map((v, i) => {
                                this.$set(item.sub_module, i, {
                                    key: v.key,
                                    value: false,
                                });
                            });
                        }
                        this.$set(
                            this.form.manPowerOutSourcingInput,
                            index,
                            item
                        );
                        this.calculateTotalManMonth();
                    });
                })
                .catch(() => {
                    this.startCell = -1;
                    this.endCell = -1;
                    this.form.manPowerOutSourcingInput.map((item, index) => {
                        if (item.sub_module) {
                            item.sub_module.map((v, i) => {
                                this.$set(item.sub_module, i, {
                                    key: v.key,
                                    value: false,
                                });
                            });
                        }
                        this.$set(
                            this.form.manPowerOutSourcingInput,
                            index,
                            item
                        );
                    });
                });
        },
        addAllManWeek_income(value){
            this.form.projectIncome.map((item, index) => {
                if (item.sub_module) {
                    item.sub_module.map((v, i) => {
                        if (v.value) {
                            this.$set(item.input, v.key, value);
                        }
                    });
                }
            });
        },
        addAllManWeek_old(value) {
            this.form.historyManPowerInput.map((item, index) => {
                if (item.sub_module) {
                    item.sub_module.map((v, i) => {
                        if (v.value) {
                            this.$set(item.input, v.key, value);
                        }
                    });
                }
            });
        },
        addAllManWeek(value) {
            this.form.manPowerInput.map((item, index) => {
                if (item.sub_module) {
                    item.sub_module.map((v, i) => {
                        if (v.value) {
                            this.$set(item.input, v.key, value);
                        }
                    });
                }
            });
        },
        addAllManWeek_outside(value) {
            this.form.manPowerOutSourcingInput.map((item, index) => {
                if (item.sub_module) {
                    item.sub_module.map((v, i) => {
                        if (v.value) {
                            this.$set(item.input, v.key, value);
                        }
                    });
                }
            });
        },

        objectSpanMethod_purchaseCost({ rowIndex, columnIndex }) {
            if (columnIndex === this.form.allMonths.length + 3) {
                if (rowIndex === 0) {
                    return {
                        rowspan: this.form.purchaseCost.length,
                        colspan: 1,
                    };
                } else {
                    return {
                        rowspan: 0,
                        colspan: 0,
                    };
                }
            }
        },
        objectSpanMethod_productionCost({ rowIndex, columnIndex }) {
            if (columnIndex === this.form.allMonths.length + 3) {
                if (rowIndex === 0) {
                    return {
                        rowspan: this.form.productionCost.length,
                        colspan: 1,
                    };
                } else {
                    return {
                        rowspan: 0,
                        colspan: 0,
                    };
                }
            }
        },
        objectSpanMethod_outsourcingProjectCost({ rowIndex, columnIndex }) {
            if (columnIndex === this.form.allMonths.length + 3) {
                if (rowIndex === 0) {
                    return {
                        rowspan: this.form.outsourcingProjectCost.length,
                        colspan: 1,
                    };
                } else {
                    return {
                        rowspan: 0,
                        colspan: 0,
                    };
                }
            }
        },
        objectSpanMethod_labourCost({ rowIndex, columnIndex }) {
            if (columnIndex === this.form.allMonths.length + 2) {
                if (rowIndex === 0) {
                    return {
                        rowspan: this.form.labourCost.length,
                        colspan: 1,
                    };
                } else {
                    return {
                        rowspan: 0,
                        colspan: 0,
                    };
                }
            }
        },
        objectSpanMethod_domesticTravel({ rowIndex, columnIndex }) {
            if (columnIndex === this.form.allMonths.length + 2) {
                if (rowIndex === 0) {
                    return {
                        rowspan: this.form.domesticTravel.length,
                        colspan: 1,
                    };
                } else {
                    return {
                        rowspan: 0,
                        colspan: 0,
                    };
                }
            }
        },
        objectSpanMethod_foreignTravel({ rowIndex, columnIndex }) {
            if (columnIndex === this.form.allMonths.length + 2) {
                if (rowIndex === 0) {
                    return {
                        rowspan: this.form.foreignTravel.length,
                        colspan: 1,
                    };
                } else {
                    return {
                        rowspan: 0,
                        colspan: 0,
                    };
                }
            }
        },
        objectSpanMethod_rent({ rowIndex, columnIndex }) {
            if (columnIndex === this.form.allMonths.length + 2) {
                if (rowIndex === 0) {
                    return {
                        rowspan: this.form.rent.length,
                        colspan: 1,
                    };
                } else {
                    return {
                        rowspan: 0,
                        colspan: 0,
                    };
                }
            }
        },
        objectSpanMethod_operation({ rowIndex, columnIndex }) {
            if (columnIndex === this.form.allMonths.length + 2) {
                if (rowIndex === 0) {
                    return {
                        rowspan: this.form.operation.length,
                        colspan: 1,
                    };
                } else {
                    return {
                        rowspan: 0,
                        colspan: 0,
                    };
                }
            }
        },
        objectSpanMethod_it({ rowIndex, columnIndex }) {
            if (columnIndex === this.form.allMonths.length + 2) {
                if (rowIndex === 0) {
                    return {
                        rowspan: this.form.it_cost.length,
                        colspan: 1,
                    };
                } else {
                    return {
                        rowspan: 0,
                        colspan: 0,
                    };
                }
            }
        },
        objectSpanMethod_depreciation({ rowIndex, columnIndex }) {
            if (columnIndex === this.form.allMonths.length + 2) {
                if (rowIndex === 0) {
                    return {
                        rowspan: this.form.depreciation.length,
                        colspan: 1,
                    };
                } else {
                    return {
                        rowspan: 0,
                        colspan: 0,
                    };
                }
            }
        },
        objectSpanMethod_assets({ rowIndex, columnIndex }) {
            if (columnIndex === this.form.allMonths.length + 2) {
                if (rowIndex === 0) {
                    return {
                        rowspan: this.form.assets.length,
                        colspan: 1,
                    };
                } else {
                    return {
                        rowspan: 0,
                        colspan: 0,
                    };
                }
            }
        },
        objectSpanMethod_immaterial({ rowIndex, columnIndex }) {
            if (columnIndex === this.form.allMonths.length + 2) {
                if (rowIndex === 0) {
                    return {
                        rowspan: this.form.immaterial.length,
                        colspan: 1,
                    };
                } else {
                    return {
                        rowspan: 0,
                        colspan: 0,
                    };
                }
            }
        },
        financeTableExc() {
            var wb = XLSX.utils.table_to_book(
                document.querySelector('#financeTable')
            );
            var wbout = XLSX.write(wb, {
                bookType: 'xlsx',
                bookSST: true,
                type: 'array',
            });
            try {
                FileSaver.saveAs(
                    new Blob([wbout], {
                        type: 'application/octet-stream;charset=utf-8',
                    }),
                    'financeTableExc.xlsx'
                );
            } catch (e) {
                if (typeof console !== 'undefined') console.log(e, wbout);
            }
            this.financeTableExcDialog = false;
            return wbout;
        },
        outExc_old() {
            var wb = XLSX.utils.table_to_book(
                document.querySelector('#outTab_old')
            );
            var wbout = XLSX.write(wb, {
                bookType: 'xlsx',
                bookSST: true,
                type: 'array',
            });
            try {
                FileSaver.saveAs(
                    new Blob([wbout], {
                        type: 'application/octet-stream;charset=utf-8',
                    }),
                    'outExc_old.xlsx'
                );
            } catch (e) {
                if (typeof console !== 'undefined') console.log(e, wbout);
            }
            this.outExc_oldDialog = false;
            return wbout;
        },
        outExc_new() {
            let wb = XLSX.utils.table_to_book(
                document.querySelector('#outTab_new')
            );
            let wbout = XLSX.write(wb, {
                bookType: 'xlsx',
                bookSST: true,
                type: 'array',
            });
            try {
                FileSaver.saveAs(
                    new Blob([wbout], {
                        type: 'application/octet-stream;charset=utf-8',
                    }),
                    'outExc_new.xlsx'
                );
            } catch (e) {
                if (typeof console !== 'undefined') console.log(e, wbout);
            }
            this.outExc_newDialog = false;
            return wbout;
        },
        outsourceExc() {
            let wb = XLSX.utils.table_to_book(
                document.querySelector('#outsourceTab')
            );
            let wbout = XLSX.write(wb, {
                bookType: 'xlsx',
                bookSST: true,
                type: 'array',
            });
            try {
                FileSaver.saveAs(
                    new Blob([wbout], {
                        type: 'application/octet-stream;charset=utf-8',
                    }),
                    'outsourceExc.xlsx'
                );
            } catch (e) {
                if (typeof console !== 'undefined') console.log(e, wbout);
            }
            this.outsourceExc_Dialog = false;
            return wbout;
        },
        arraySpanMethod({ row, column, rowIndex, columnIndex }) {
            if (columnIndex === 2) {
                return [7, 0];
            } else {
                return [0, 0];
            }
        },
        strDateIsBeforeCurDate: function (index) {
            const current = new Date();
            let start = new Date(this.form.project_start_date);
            start.setMonth(start.getMonth() + index + 1);
            return start < current;
        },
        EditorValueFn() {
            this.$axios.get(
                `${this.BACKEND_API}/api/base/project/add_joint?workflow_id=${this.form.form_id}&ldap=${this.ldap}`,
            )
            .then((res) => {
                this.EditorValue = res.data.data;
            })
            .catch((err) => {
                console.log(err);
            });
        },
        EditorStateChange(item) {
            this.editorState_id = item.id;
            this.editorState_ldap = item.ldap;
        },
        lok() {
            let data = {
                workflow_id : this.form.form_id,
                user_ldap : this.ldap,
                joint_ldap : this.editorState_ldap
            }
            if (this.editorState_id) {
                this.$axios.post(
                        `${this.BACKEND_API}/api/base/project/add_joint`,data
                    ).then((res) => {
                        console.log(res);
                        this.EditorValueFn();
                        this.lokAdd = false;
                        this.editorState = '';
                        this.editorState_id = '';
                        this.editorState_ldap = '';
                        this.$message.success('添加成功');
                    });
            } else {
                this.$message.error('添加失败，请选择用户');
            }
        },
        EditorValueDel(item) {
            let data = {
                workflow_id : this.form.form_id,
                user_ldap : this.ldap,
                joint_ldap : item.ldap
            }
            this.$axios.post(
                `${this.BACKEND_API}/api/base/project/delete`,data
            ).then(res=>{
                this.EditorValueFn();
            })
        },
        addEditor() {
            this.lokAdd = false;
            this.addEditorShow = true;
            this.EditorValueFn();
        },
        handleClose(done) {
            this.$confirm('确认关闭？')
                .then((_) => {
                    done();
                    this.addEditorShow = false;
                    this.lokAdd = false;
                    this.editorState = '';
                })
                .catch((_) => {});
        },
        customer_full_name_value() {
            this.form.customer_id == ''
                ? (this.form.customer_full_name = '')
                : '';
        },
        corporation_value() {
            this.form.corporation_id == '' ? (this.form.corporation = '') : '';
        },
        sales_value() {
            this.form.sales_id == '' ? (this.form.sales = '') : '';
        },
        project_director_value() {
            this.form.project_director_id == ''
                ? (this.form.project_director = '')
                : '';
        },
        project_manager_value(){
            this.form.project_manager_id == ''
                ? (this.form.project_manager = '')
                : '';
        },
        business_department_value() {
            this.form.business_department_id == ''
                ? (this.form.business_department = '')
                : '';
        },
        implement_department_company_value(row){
            if(row.implement_department_id){
                row.implement_department_id === '' 
                    ? row.implement_department = ''
                    : '';
            }else{
                let obj = 'implement_department_id'
                row[obj] = ''
                row.implement_department = ''
            }
        },
        copyLinkSuccess(e) {
            this.$message({
                message: '已复制到粘贴板！',
                type: 'success',
            });
        },
        calcLabourMonthColumn(index) {
            let sum = 0;
            for (const row of this.form.labourCost) {
                sum += parseFloat(row.values[index]);
            }
            sum +=
                parseFloat(
                    this.form.labourOtherCost[0].input[
                        index 
                    ]
                ) || 0;
            return this.num45Filter(sum);
        },
        sum(array) {
            return array.reduce(
                (a, b) => parseFloat(a || '0') + parseFloat(b || '0'),
                0
            );
        },
        distributionCalc(
            row,
            manPowerInput,
            constants,
            group_salary_cost,
            housing_fund_rate
        ) {
            return distributionCalc(
                row,
                manPowerInput,
                constants,
                group_salary_cost,
                housing_fund_rate
            );
        },
        num45Filter(amount, decimalCount = 2, decimal = '.', thousands = ',') {
            try {
                decimalCount = Math.abs(decimalCount);
                decimalCount = isNaN(decimalCount) ? 2 : decimalCount;

                const negativeSign = amount < 0 ? '-' : '';
                let tempVal = Math.pow(10, 2);
                let i = parseInt(
                    (amount = Math.abs(
                        Number(Math.round(amount * tempVal) / tempVal) || 0
                    ).toFixed(decimalCount))
                ).toString();
                let j = i.length > 3 ? i.length % 3 : 0;

                return (
                    negativeSign +
                    (j ? i.substr(0, j) + thousands : '') +
                    i.substr(j).replace(/(\d{3})(?=\d)/g, '$1' + thousands) +
                    (decimalCount
                        ? decimal +
                          Math.abs(amount - i)
                              .toFixed(decimalCount)
                              .slice(2)
                        : '')
                );
            } catch (e) {
                console.log(e);
            }
        },
        getSummaries(param) {
            const { columns, data } = param;
            const sums = [];
            columns.forEach((column, index) => {
                if (index === 0) {
                    sums[index] = '';
                    return;
                }
            });
            return sums;
        },
        removeManPowerRow(row) {
            let rowIndex = this.form.manPowerInput.indexOf(row);
            this.form.manPowerInput.splice(rowIndex, 1);
            this.calculateTotalManMonth();
            this.calculateQuotation();
        },
        removeStagePlan(row) {
            let rowIndex = this.form.stagePlans.indexOf(row);
            this.form.stagePlans.splice(rowIndex, 1);
        },
        removePowerOutSourcingRow(row) {
            let rowIndex = this.form.manPowerOutSourcingInput.indexOf(row);
            this.form.manPowerOutSourcingInput.splice(rowIndex, 1);
            this.calculateTotalManMonth();
            this.calculateQuotation();
        },
        removeIncomeDistributionRow(row) {
            let rowIndex = this.form.incomeDistribution.indexOf(row);
            this.form.incomeDistribution.splice(rowIndex, 1);
        },
        message(msg, type) {
            this.messagePromise = this.messagePromise
                .then(this.$nextTick)
                .then(() => {
                    this.$message({
                        message: msg,
                        type: type,
                    });
                });
        },
        changTime(projectName){
            return new Promise((resolve,reject) =>{
                this.$axios.get(
                    `${this.BACKEND_API}/api/base/project/change_time?project_name=${projectName}`
                ).then(res=>{
                    if(res.data.status){
                        resolve(res.data.date);
                    }else{
                        resolve('')
                    }
                }).catch(err =>{
                    reject(err);
                })
            })
        },
        loadFormData(formId , projectName) {
                this.$axios.get(
                    `${this.BACKEND_API}/api/base/project/apply?id=${formId}&project_name=${projectName}`
                ).then((res) => {
                    if (res.data.code === 200) {
                        let isCreator = res.data.creator_ldap === this.ldap;
                        let isCollaborator = res.data.collaborators.find(x => x === this.ldap) !== undefined;
                        this.jointEdit(res.data.data.form.form_id,this.ldap).then( jointEdit =>{
                            if(!(isCreator || isCollaborator) && !jointEdit){
                                this.$router.push({
                                    name: 'view',
                                    params: { id: this.$route.params.id },
                                });
                                return false;
                            }
                        })
                        this.version = res.data.version;
                        this.requestType = res.data.request_type;
                        for (const d in res.data.data.form) {
                            this.form[d] = res.data.data.form[d];
                        }
                        if(this.form.incomeDistribution.length < 1){
                            let rowCount = res.data.data.form.incomeDistribution.length;
                            let bu = res.data.data.form.business_department
                            let j = {
                                id: rowCount + 1,
                                implement_department: bu || '',
                                implement_department_id: res.data.data.form.business_department_id || '',
                                type: bu ? 'bu' : '',
                                percentage: bu ? 25 : 0,  
                                income: 0,
                                manager: '',
                                manager_id: res.data.data.form.project_manager_id,
                                abbr_name: '',
                                cost: 0,
                                sub_project_name: res.data.data.form.project_name,
                                sub_project_id: '',
                                history_cost: '0',
                                canDelete: false
                            };
                            this.form.incomeDistribution.push(j)
                        }
                        if( this.form.incomeDistribution[0] ){
                            this.form.incomeDistribution[0].sub_project_name = res.data.data.form.project_name,
                            this.form.incomeDistribution[0].manager_id = res.data.data.form.project_manager_id
                        }
                        if (
                            res.data.data.form.project_start_date &&
                            res.data.data.form.project_end_date
                        ) {
                            // 计算项目周期
                            this.changTime(projectName).then(currentDate=>{
                                let { pastMonths, nextMonths } = getProjectPeriods(
                                    res.data.data.form.project_start_date,
                                    res.data.data.form.project_end_date,
                                    this.requestType === 1,
                                    currentDate
                                );
                                if (this.requestType === 1 && this.mode !== 'view') {
                                    let start = new Date(
                                        res.data.data.form.project_start_date
                                    );
                                    let end = new Date(
                                        res.data.data.form.project_end_date
                                    );
                                    const duration = end.getTime() - start.getTime();
                                    const monthDuration =
                                        duration / (24 * 60 * 60 * 30 * 1000);
                                    let projectPeriod =
                                        Math.floor(monthDuration * 10) / 10;
                                    this.form.created_at =
                                        res.data.data.form.created_at;
                                    this.form.oldProjectPeriod = this.getDuration(
                                        this.form.init_project_end_date,
                                        this.form.init_project_start_date
                                    );
                                    this.projectPeriod = projectPeriod;
                                    this.form.project_period = projectPeriod;
                                    this.form.pastMonths = pastMonths;
                                    this.form.nextMonths = nextMonths;
                                    this.form.allMonths = pastMonths.concat(nextMonths);
                                } else if (
                                    this.requestType === 1 &&
                                    this.mode === 'view'
                                ) {
                                    console.log('load months');
                                    this.form.pastMonths = pastMonths;
                                    this.form.nextMonths = nextMonths;
                                    this.form.allMonths = pastMonths.concat(nextMonths);
                                } else {
                                    this.form.pastMonths = [];
                                    this.form.nextMonths = nextMonths;
                                    this.form.allMonths = nextMonths;
                                }
                                // 初始化历史人力  
                                if (this.requestType === 1 && res.data.data.form.historyManPowerInput && res.data.data.form.historyManPowerInput[0].input.length < 1) {
                                    this.customerLevel();
                                    this.form.historyManPowerInput = initHistoryLabourInput(
                                        Math.ceil(pastMonths.length)
                                    );
                                    // 分配公司人力历史
                                    this.form.historyManPowerInput[0].input = sumTotalManMonthList(
                                        res.data.data.form.manPowerInput
                                    ).slice(0, pastMonths.length);
                                }
                                this.form.historyManPowerInput.forEach(
                                    (item, index) => {
                                        if (
                                            item.input.length <
                                            this.form.pastMonths.length
                                        ) {
                                            let arr = new Array(
                                                this.form.pastMonths.length -
                                                    item.input.length
                                            ).fill(0);
                                            this.form.historyManPowerInput[
                                                index
                                            ].input = this.form.historyManPowerInput[
                                                index
                                            ].input.concat(arr);
                                        }
                                    }
                                );
                                // 载入公司人力
                                if(res.data.data.form.manPowerInput){
                                    res.data.data.form.manPowerInput.forEach(
                                        (item, index) => {
                                            if (item.input.length < this.form.nextMonths.length) {
                                                this.form.manPowerInput[
                                                    index
                                                ].input = item.input.concat(
                                                    new Array(
                                                        this.form.nextMonths.length
                                                    ).fill(0)
                                                )
                                            }
                                            if (
                                                this.requestType === 1 && 
                                                res.data.data.form.historyManPowerInput && 
                                                res.data.data.form.historyManPowerInput[0].input.length < 1
                                            ) {
                                                // 分配公司人力预测
                                                this.form.manPowerInput[
                                                    index
                                                ].input = item.input.slice(
                                                    pastMonths.length
                                                );
                                            }
                                        }
                                    );
                                }
                                // 载入外包人力
                                if(res.data.data.form.manPowerOutSourcingInput){
                                    res.data.data.form.manPowerOutSourcingInput.forEach(
                                        (item, index) => {
                                            if(item.input.length < this.form.allMonths.length){
                                                this.form.manPowerOutSourcingInput[
                                                    index
                                                ].input = item.input.concat(
                                                    new Array(
                                                        this.form.allMonths.length - item.input.length
                                                    ).fill(0)
                                                );
                                            }
                                            if (
                                                this.requestType === 1 && 
                                                res.data.data.form.historyManPowerInput && 
                                                res.data.data.form.historyManPowerInput[0].input.length < 1
                                            ) {
                                                // 分配外包人力预测
                                                this.form.manPowerOutSourcingInput[
                                                    index
                                                ].input = item.input;
                                            }
                                        }
                                    );
                                }
                                // 载入拆分部门Id
                                if(res.data.data.form.incomeDistribution){
                                    res.data.data.form.incomeDistribution.forEach(
                                        (item, index) => {
                                            if (
                                                !item.hasOwnProperty(
                                                    'implement_department_id' &&
                                                        item.hasOwnProperty(
                                                            'implement_department'
                                                        )
                                                )
                                            ) {
                                                this.getDepartmentId(
                                                    item.implement_department
                                                ).then((data) => {
                                                    this.form.incomeDistribution[
                                                        index
                                                    ].implement_department_id = data.id;
                                                });
                                            }
                                    });
                                }
                                // 载入子项目Id
                                if(res.data.data.form.incomeDistribution){
                                    res.data.data.form.incomeDistribution.forEach(
                                        (item, index) => {
                                            if (this.mode === 'change') {
                                                if (
                                                    item.hasOwnProperty('sub_project_name')
                                                ) {
                                                    this.form.enableSubProjectName = true;
                                                } else {
                                                    this.form.enableSubProjectName = false;
                                                }
                                            }
                                            item.history_cost === '' ? 0 : this.form.incomeDistribution[index].history_cost
                                            if(item.history_cost == undefined){
                                                let obj = 'history_cost'
                                                this.form.incomeDistribution[index][obj] = 0;
                                            }
                                            this.getSubProjectId(
                                                item.sub_project_name
                                            ).then((data) => {
                                                this.form.incomeDistribution[
                                                    index
                                                ].sub_project_id = data.id 
                                                if(data.id !== null || data.id != undefined){
                                                    this.form.incomeDistribution[
                                                        index
                                                    ].canDelete = false
                                                    if(index > 0){
                                                        this.$axios.get(
                                                            `${process.env.VUE_APP_PROJECT_REQUEST_HOST}/oracle_view?project_name=${item.sub_project_name}`
                                                        ).then(res=>{
                                                            this.form.incomeDistribution[index].implement_department_id = 
                                                                res.data.ssbm;
                                                            this.form.incomeDistribution[index].implement_department = 
                                                                res.data.ssbmmc;
                                                            this.form.incomeDistribution[index].manager_id = 
                                                                res.data.xmglry;
                                                            this.form.incomeDistribution[index].manager = 
                                                                res.data.xmglryxm;
                                                        })
                                                    }
                                                }
                                            });
                                        });
                                }
                                if(res.data.data.form.projectIncome){
                                    res.data.data.form.projectIncome.forEach(
                                        (item,index)=>{
                                            if(item.input.length < this.form.allMonths.length){
                                                this.form.projectIncome[
                                                    index
                                                ].input = item.input.concat(
                                                    new Array(
                                                        this.form.allMonths.length - item.input.length
                                                    ).fill(0)
                                                );
                                            }
                                        }
                                    )
                                }
                            });
                        }
                        this.labourCost = res.data.data.form.labourCost;
                        this.oldForm = res.data.data.form_old;
                        this.oldCalculated = res.data.data.calculated_old;
                        this.estCost = res.data.data.calculated.est_cost;
                        this.estIncome = res.data.data.calculated.est_income;
                        this.estIncomeRaw = res.data.data.calculated.est_income_raw;
                        this.profit = res.data.data.calculated.profit;
                        this.profit_rate = res.data.data.calculated.profit_rate;
                        this.totalManMonth =
                            res.data.data.calculated.total_man_month;
                        this.avgCostRMB = res.data.data.calculated.avg_cost_RMB;
                        let readValue = this.form.project_level;
                        this.form.project_level = readValue.toString();
                        let readValue2 = this.form.security_level;
                        this.form.security_level = readValue2.toString();
                        let readValue3 = this.form.est_market_size_over_20_million;
                        this.form.est_market_size_over_20_million = 
                            readValue3.toString()
                        ;
                        if(this.form.software_platform){
                            this.form.software_platform = parseFloat(this.form.software_platform);
                        }
                        if(this.form.hardware_platform){
                            this.form.hardware_platform = parseFloat(this.form.hardware_platform);
                        }
                        if(this.form.income_check_method){
                            this.form.income_check_method = parseFloat(this.form.income_check_method);
                        }
                        let xmgy  =  this.form.project_summary
                        this.form.project_summary = xmgy.replace(/\&nbsp;/g," ",).replace(/<br>/g,'\n').replace(/<br \/>/g,'\n');
                        // 重新渲染项目经理
                        this.xmjlxm(this.form.project_manager_id)
                            .then(data=>{
                                if(data.name_zh){
                                    this.form.project_manager = data.name_zh;
                                }
                        });
                        // 项目状态为可编辑时触发重新计算
                        this.projectStatusValue(this.form.form_id)
                        .then((data)=>{ 
                            if(data.status === 1 || data.status === null){
                                this.calculateTotalManMonth();
                                this.calculateTotalIncome();
                            }else{
                                // 项目状态为不可编辑时跳转至view页面
                                this.$router.push({
                                    name: 'view',
                                    params: { id: this.$route.params.id },
                                });
                            }
                        })
                    } else {
                        this.errMessage = '无效的请求';
                    }
                });
            
        },
        jointEdit(formId,ldap){
            return new Promise((resolve,reject) =>{
                this.$axios.get(
                        `${this.BACKEND_API}/api/base/project/joint_edit?workflow_id=${formId}&ldap=${ldap}`
                    ).then(res =>{
                        resolve(res.data.status)
                    })
            })
        },
        xmjlxm(id){
            return new Promise((resolve, reject)=>{
                this.$axios
                    .post(
                        `${process.env.VUE_APP_PROJECT_REQUEST_HOST}/api/base/project/status?`,{
                            id:id
                        }
                    )
                    .then((res) =>{
                        resolve(res.data.data)
                    })
                    .catch((err) =>{
                        reject(err)
                    })
            })
        },
        // 判断项目状态
        projectStatusValue(id){
            return new Promise((resolve, reject)=>{
                this.$axios
                    .get(
                        `${process.env.VUE_APP_PROJECT_REQUEST_HOST}/api/base/project/status?id=${id}`,
                    )
                    .then((res) =>{
                        resolve(res.data.data)
                    })
                    .catch((err) =>{
                        reject(err)
                    })
            })
        },
        canEditProjectName() {
            if (this.mode === 'create' && this.form.form_id === null) {
                return true;
            } else if (this.mode === 'change') {
                return true;
            } else {
                return false;
            }
        },
        uploadSuccess(res, file) {
            if (res.code == 201) {
                this.form.file_list.push({
                    path: res.msg,
                    fileName: file.name,
                });
            }
        },
        uploadSpecialApprovalSuccess(res, file) {
            if (res.code == 201) {
                this.form.special_approval_list.push({
                    path: res.msg,
                    fileName: file.name,
                });
            }
        },
        submitUpload() {
            this.$refs.upload.submit();
        },
        submitSpecialApprovalUpload() {
            this.$refs.uploadSpecialApproval.submit();
        },
        loadLocalFormData() {
            let localForm = localStorage.getItem('form');
            let localCalculated = localStorage.getItem('calculated');
            let formData = JSON.parse(localForm);
            let calculatedData = JSON.parse(localCalculated);
            if (localForm === null) {
                this.loading = false;
            } else {
                for (const d in formData) {
                    this.form[d] = formData[d];
                }
                this.estCost = calculatedData.est_cost;
                this.estIncome = calculatedData.est_income;
                this.estIncomeRaw = calculatedData.est_income_raw;
                this.profit = calculatedData.profit;
                this.profit_rate = calculatedData.profit_rate;
                this.totalManMonth = calculatedData.total_man_month;
                this.avgCostRMB = calculatedData.avg_cost_RMB;
                this.loading = false;
                this.$notify.success('已载入保存数据');
            }
        },
        saveForm: lodash.debounce(function () {
            if (!window.localStorage) {
                this.$notify.warning('自动保存失败，请使用现代浏览器');
                return false;
            }
            let storage = window.localStorage;
            storage.setItem('form', JSON.stringify(this.form));
            storage.setItem('calculated', JSON.stringify(this.getCalculated()));
        }, 2500),
        displayCustomerLevel(levelNum) {
            switch (levelNum) {
                case '0':
                    return 'A级';
                case '1':
                    return 'B级';
                case '2':
                    return 'C级';
                case '3':
                    return 'D级';
                case '4':
                    return '暂不评级';
                case '5':
                    return '黑名单';
                case '6':
                    return 'HWA';
                case '7':
                    return 'HWB';
                case '8':
                    return 'HWC';
                case '9':
                    return 'I级';
                case '10':
                    return 'II级';
                case '11':
                    return 'E级';
                default:
                    return '';
            }
        },
        init_reckon() {
            console.log('init_reckon');
        },
        getdataPro() {
            return http.get(`/api/account/user/info`);
        },
        async getname() {
            try {
                const data = await this.getdataPro();   
                this.username = data.data;
                // // this.form.project_manager = data.data;
                // if (this.mode === 'create') {
                //     this.form.project_manager = data.data;
                // }
            } catch (err) {
                throw err;
            }
        },
        formSave(data) {
            return new Promise((resolve, reject) => {
                if (this.mode !== 'change') {
                    this.calculateTotalManMonth();
                    this.calculateTotalIncome();
                }
                this.$axios({
                    url: `${this.BACKEND_API}/api/base/project/apply`,
                    method: 'post',
                    data: data,
                })
                .then((response) => {
                    resolve(response);
                })
                .catch((err) => {
                    reject(err);
                });
            });
        },
         submitForm: lodash.debounce(function (action) {
            if (this.projectIcon === 'el-icon-close') {
                this.$message.error('项目已存在，请使用其它项目名');
                return false;
            } else {
                    // 清空工数单元格class
                    for (let i in this.form.manPowerInput) {
                        this.form.manPowerInput[i].sub_module = '';
                    }
                    for (let i in this.form.historyManPowerInput) {
                        this.form.historyManPowerInput[i].sub_module = '';
                    }
                    for (let i in this.form.manPowerOutSourcingInput) {
                        this.form.manPowerOutSourcingInput[i].sub_module = '';
                    }
                    for (let i in this.form.projectIncome) {
                        this.form.projectIncome[i].sub_module = '';
                    }
                    this.getUserInfo().then(res =>{
                            if(this.requestType === 1){
                            // update project_manager_id
                            this.form.project_manager_id =  res.data.data[0].id;
                                this.getSubProjectId(this.form.project_name).then(data=>{
                                    this.form.project_id = data.id
                                })
                            }
                            let form_data = Object.assign({}, this.form);
                            let data = {
                                //因为汇率原因，总投入，毛利，毛利率3个字段无法实时显示， 建议废除这三个字段，直接使用公式展示
                                form: form_data,
                                form_old: this.oldForm,
                                calculated: this.getCalculated(),
                                calculated_old: this.oldCalculated,
                            };
                            this.formSave(data).then((res) => {
                                if (res.data.code === 201) {
                                    if (this.$route.name === 'create') {
                                        this.$router.push({
                                            name: 'edit',
                                            params: { id: res.data.data.form_id },
                                        });
                                    }
                                    this.customerLevel();
                                    this.form.form_id = res.data.data.id;
                                    this.form.form_form_id = res.data.data.form_id;
                                    this.message('保存成功', 'success');
                                    if (
                                        action === 'submit' ||
                                        action === 'submit-force' ||
                                        action === 'preservation'
                                    ) {
                                        // 检查阶段点
                                        let checkStagePointResult = checkStagePoint(
                                            this.totalManMonth,
                                            this.estIncomeRaw * this.form.currency,
                                            this.estCost,
                                            this.form.stagePlans
                                        );
                                        if (
                                            (this.form.business_type[1] == '23' ||
                                                this.form.business_type[1] == '0' ||
                                                this.form.business_type[1] == '8') &&
                                            this.form.business_type[0] == '0' &&
                                            this.form.is_pre_dev === false &&
                                            this.form.entire_subcontract === false &&
                                            checkStagePointResult.isValid === false
                                        ) {
                                            this.$message({
                                                type: 'warning',
                                                showClose: true,
                                                message: checkStagePointResult.errMsg,
                                                duration: 0,
                                            });
                                            if (
                                                action === 'submit' ||
                                                action === 'submit-force'
                                            ) {
                                                return false;
                                            }
                                        }
                                        // 检查工时管理员
                                        let checkImplDeptManagerResult = checkImplDeptManager(
                                            this.form.incomeDistribution,
                                            this.form.business_department_id
                                        );
                                        if (
                                            checkImplDeptManagerResult.isValid === false &&
                                            this.form.enableSubProjectName
                                        ) {
                                            this.$message({
                                                type: 'warning',
                                                showClose: true,
                                                message: checkImplDeptManagerResult.errMsg,
                                                duration: 0,
                                            });
                                            if (
                                                action === 'submit' ||
                                                action === 'submit-force'
                                            ) {

                                                return false;
                                            }
                                        }
                                        if (this.form.corporation_id === '') {
                                            this.$message({
                                                type: 'warning',
                                                showClose: true,
                                                message:
                                                    '基础信息：请从下拉框中重新选择公司全称(合同签署)',
                                                duration: 0,
                                            });
                                        }
                                        if (this.form.customer_id === '') {
                                            this.$message({
                                                type: 'warning',
                                                showClose: true,
                                                message:
                                                    '基础信息：请从下拉框中重新选择客户全称',
                                                duration: 0,
                                            });
                                        }
                                        if (this.form.business_department_id === '') {
                                            this.$message({
                                                type: 'warning',
                                                showClose: true,
                                                message:
                                                    '基础信息：请从下拉框中重新选择所属事业部',
                                                duration: 0,
                                            });
                                        }
                                        if (this.form.project_manager_id === '') {
                                            this.$message({
                                                type: 'warning',
                                                showClose: true,
                                                message:
                                                    '基础信息：请从下拉框中重新选择项目经理',
                                                duration: 0,
                                            });
                                        }
                                        if (this.form.sales_id === '') {
                                            this.$message({
                                                type: 'warning',
                                                showClose: true,
                                                message:
                                                    '基础信息：请从下拉框中重新选择销售人员',
                                                duration: 0,
                                            });
                                        }
                                        if (this.form.project_director_id === '') {
                                            this.$message({
                                                type: 'warning',
                                                showClose: true,
                                                message:
                                                    '基础信息：请从下拉框中重新选择项目总监',
                                                duration: 0,
                                            });
                                        }
                                        if(this.requestType === 1){
                                            if(this.form.init_project_start_date === '' ){
                                                this.$message({
                                                    type: 'warning',
                                                    showClose: true,
                                                    message:
                                                        '立项时项目开始日期为空',
                                                    duration: 0,
                                                });
                                                if (
                                                    action === 'submit' ||
                                                    action === 'submit-force'
                                                ) {
                                                    return false;
                                                }
                                            }else if(this.form.init_project_end_date === ''){
                                                this.$message({
                                                    type: 'warning',
                                                    showClose: true,
                                                    message:
                                                        '立项时项目结束日期为空',
                                                    duration: 0,
                                                });
                                                if (
                                                    action === 'submit' ||
                                                    action === 'submit-force'
                                                ) {
                                                    return false;
                                                }
                                            }
                                        }
                                        if(this.form.special_approval === ''){
                                            this.$message({
                                                type: 'warning',
                                                showClose: true,
                                                message:
                                                    '特批事项:利润率特批申请审批通过的内容不能为空',
                                                duration: 0,
                                            });
                                                return false;
                                        }
                                        // validate sumPercentage() equals 100
                                        if (this.sumPercentage() !== 100) {
                                            this.$message({
                                                type: 'warning',
                                                showClose: true,
                                                message:
                                                    '收入拆分：收入拆分总比例必须为100',
                                                duration: 0,
                                            });
                                                return false;
                                        }
                                        for (let i in this.form.incomeDistribution) {
                                            if(this.form.incomeDistribution[i].implement_department_id == '' || this.form.incomeDistribution[i].implement_department_id == undefined){
                                                this.$message({
                                                    type: 'warning',
                                                    showClose: true,
                                                    message:
                                                        '收入拆分:实施部门id不能为空',
                                                    duration: 0,
                                                });
                                                    return false;
                                            }
                                            if (
                                                this.form.incomeDistribution[i]
                                                    .history_cost === '' &&
                                                this.form.enableSubProjectName
                                            ) {
                                                this.$message({
                                                    type: 'warning',
                                                    showClose: true,
                                                    message:
                                                        '收入拆分:历史人力成本+折旧摊销不能为空',
                                                    duration: 0,
                                                });
                                                    return false;
                                            }
                                        }
                                        for (let manPower of this.form.manPowerInput) {
                                            if(manPower.implement_department === ''){
                                                    this.$message({
                                                        type: 'warning',
                                                        showClose: true,
                                                        message:
                                                            '工数预测：请从下拉框选择公司员工实施部门',
                                                        duration: 0,
                                                    });
                                                    return false;
                                                }
                                            for (const i of manPower.input) {
                                                if (i === '') {
                                                    this.$message({
                                                        type: 'warning',
                                                        showClose: true,
                                                        message:
                                                            '工数预测：公司员工工数预测包含空值, 请填0',
                                                        duration: 0,
                                                    });
                                                    return false;
                                                }
                                            }
                                        }
                                        for (let manPower of this.form
                                            .manPowerOutSourcingInput) {
                                            if(!manPower.isTotal){
                                                if(manPower.implement_department === ''){
                                                    this.$message({
                                                        type: 'warning',
                                                        showClose: true,
                                                        message:
                                                            '工数预测：请从下拉框选择外协人员实施部门',
                                                        duration: 0,
                                                    });
                                                    return false;
                                                }
                                                for (const i of manPower.input) {
                                                    if (i === '') {
                                                        this.$message({
                                                            type: 'warning',
                                                            showClose: true,
                                                            message:
                                                                '工数预测：外协人员工数预测包含空值, 请填0',
                                                            duration: 0,
                                                        });
                                                        return false;
                                                    }
                                                }
                                            }
                                        }
                                        this.$refs['baseForm'].validate((valid) => {
                                            if (valid) {
                                                if (
                                                    action === 'submit' ||
                                                    action === 'submit-force'
                                                ) {
                                                    if (
                                                        process.env.NODE_ENV ===
                                                        'development'
                                                    ) {
                                                        if (action === 'submit') {
                                                            console.log(
                                                                'skip submit in development mode'
                                                            );
                                                            this.loadFormDataAsync(this.$route.params.id,this.form.project_name).then(()=>{
                                                                submitProject(
                                                                    this.ldap,
                                                                    this.form,
                                                                    this.getCalculated(),
                                                                    true
                                                                );
                                                            });
                                                        }
                                                    }
                                                    this.loading = true;
                                                    this.mode === 'create'
                                                        ? this.form.id
                                                        : this.$route.params.id;
                                                    if (this.requestType === 1) {
                                                        this.loadFormDataAsync(this.$route.params.id,this.form.project_name).then(()=>{
                                                            changeProject(
                                                                this.ldap,
                                                                this.form,
                                                                this.getCalculated(),
                                                                this.oldCalculated,
                                                                this.oldForm.form_id != ''
                                                            );
                                                        })
                                                    } else {
                                                        this.loadFormDataAsync(this.$route.params.id,this.form.project_name).then(()=>{
                                                            submitProject(
                                                                this.ldap,
                                                                this.form,
                                                                this.getCalculated(),
                                                                false
                                                            );
                                                        })
                                                    }
                                                }
                                            } else {
                                                this.$message({
                                                    type: 'warning',
                                                    showClose: true,
                                                    message: '请检查(*)必填项',
                                                    duration: 0,
                                                });
                                                return false;
                                            }
                                        });
                                    }
                                } else {
                                    this.$message.error(res.data.msg);
                                }
                        });
                    });
            }
        }, 800),
        formReset() {
            localStorage.clear();
            this.$router.go(0);
        },
        async loadFormDataAsync(formId,projectName){
            await this.loadFormData(formId,projectName);
        },
        getCalculated() {
            let incomeRMB = this.estIncomeRaw * this.form.currency;
            return {
                profit_rate: incomeRMB
                    ? ((incomeRMB - this.estCost) * 100) / incomeRMB
                    : 0,
                est_income: incomeRMB,
                total_man_month: this.totalManMonth,
                est_cost: this.estCost,
                est_income_raw: this.estIncomeRaw,
                profit: incomeRMB - this.estCost,
                avg_cost_RMB: this.totalManMonth
                    ? this.estCost / this.totalManMonth
                    : '0',
                avg_income_RMB: this.totalManMonth
                    ? incomeRMB / this.totalManMonth
                    : '0',
                submitter: this.username,
                ldap: this.ldap,
            };
        },
        formSubmit() {},
        isUndefined(para) {
            return para === void 0;
        },
        projectPeriodChanged() {
            let projectIncome = this.form.projectIncome;
            for (const i in projectIncome) {
                projectIncome[i].input = new Array(
                    this.form.allMonths.length
                ).fill(0);
            }
            this.form.projectIncome = projectIncome;
            this.form.hardwareProducts[0].input = new Array(
                this.estLabourMonth().length
            ).fill(0);
        },
        calculateTotalManMonth() {
            console.log('func:calculateTotalManMonth');
            let totalManMonth = 0;
            // 追加预测公司员工人力
            let manPowerInput = this.form.manPowerInput;
            for (let index in manPowerInput) {
                if (!manPowerInput[index].total) {
                    totalManMonth += manPowerInput[index].input.reduce(
                        (a, b) => parseFloat(a || '0') + parseFloat(b || '0'),
                        0
                    );
                }
            }
            // 追加历史公司员工人力
            if (
                this.requestType === 1 &&
                this.form.historyManPowerInput[0].hasOwnProperty('input')
            ) {
                let historyManPowerInput = this.form.historyManPowerInput;
                totalManMonth += historyManPowerInput[0].input.reduce(
                    (a, b) => parseFloat(a || '0') + parseFloat(b || '0'),
                    0
                );
            }
            // 追加预测外协人员人力
            let manPowerOutSourcingInput = this.form.manPowerOutSourcingInput;
            for (let index in manPowerOutSourcingInput) {
                if (!manPowerOutSourcingInput[index].total) {
                    totalManMonth += manPowerOutSourcingInput[
                        index
                    ].input.reduce(
                        (a, b) => parseFloat(a || '0') + parseFloat(b || '0'),
                        0
                    );
                }
            }
            this.totalManMonth = totalManMonth + parseFloat(this.form.pre_man_month || 0);
            if (this.totalManMonth && this.totalManMonth != 0) {
                this.avgCostRMB = this.estCost / this.totalManMonth;
            }
            //计算外协人员成本
            this.calculateLabourCost();
            this.calculateOutSourcingCost();
            this.calculateDepreciation(); // 计算总投入需要在计算公司员工投入后
            // 计算拆分
            this.form.incomeDistribution.forEach((item) => {
                item.cost = this.distributionCalc(
                    item,
                    this.form.manPowerInput,
                    this.form.constants,
                    this.form.group_salary_cost,
                    this.form.housing_fund_rate
                );
                item.income =
                    (item.percentage * this.estIncomeRaw * this.form.currency) /
                    100;
            });
            this.hardwareProductsValue();
        },
        avgNREIncomeRMB() {
            let projectIncome = this.form.projectIncome;
            let manMonth = projectIncome[0].input.reduce(
                (a, b) => parseFloat(a || '0') + parseFloat(b || '0'),
                0
            );
            let sum = projectIncome[2].input.reduce(
                (a, b) => parseFloat(a || '0') + parseFloat(b || '0'),
                0
            );
            return sum / manMonth;
        },
        querySearchCustomer(queryString, cb) {
            let customers = this.customers;
            let results = queryString
                ? customers.filter(this.createFilter(queryString))
                : customers;
            // 调用 callback 返回建议列表的数据
            cb(results);
        },
        querySearchCorporation(queryString, cb) {
            let corporations = this.corporations;
            let results = queryString
                ? corporations.filter(
                      this.createFilterNameAndPinyin(queryString)
                  )
                : corporations;
            // 调用 callback 返回建议列表的数据
            cb(results);
        },
        querySearchDepartment(queryString, cb) {
            let departments = [{}];
            this.$axios
                .get(`${this.BACKEND_API}/api/base/department/`, {
                    params: { format: 'json', search: queryString, level: 2 },
                })
                .then((response) => {
                    for (let i of response.data.data) {
                        i.value = i.name;
                    }
                    departments = response.data.data;
                    cb(departments);
                })
                .catch((error) => {
                    console.log(error);
                });
        },
        createFilterName(queryString) {
            return (item) => {
                return (
                    item.value.indexOf(queryString) >= 0 ||
                    item.pinyin.indexOf(queryString.toLowerCase()) >= 0
                );
            };
        },
        createFilterNameAndPinyin(queryString) {
            return (item) => {
                return item.value.indexOf(queryString) === 0;
            };
        },
        createFilter(queryString) {
            return (customer) => {
                return (
                    customer.value
                        .toLowerCase()
                        .indexOf(queryString.toLowerCase()) === 0 ||
                    customer.abbr_name
                        .toLowerCase()
                        .indexOf(queryString.toLowerCase()) === 0 ||
                    customer.pinyin.indexOf(queryString.toLowerCase()) === 0
                );
            };
        },
        handleCustomerChanged(customer) {
            this.form.customer_id = '';
            // 清空客户相关表单
            if (typeof customer != 'undefined' && customer === '') {
                this.form.customer_abrv_name = '';
                this.form.customer_region = '';
                this.form.customer_level = '';
                this.form.customer_category = '';
            }
        },
        requestChangeProject(projectId) {
            return new Promise((resolve, reject) => {
                this.$axios
                    .post(`${this.BACKEND_API}/api/base/workflow/change`, {
                        project_id: projectId,
                    })
                    .then((res) => {
                        this.loadFormData(res.data.data.form_id);
                        this.loading = false;
                        resolve(res.data.data);
                    })
                    .catch((err) => {
                        reject(err);
                    });
            });
        },
        loadProjectProperties(projectName) {
            return new Promise((resolve, reject) => {
                console.log(process.env.NODE_ENV);
                let url = '';
                if (process.env.NODE_ENV === 'development') {
                    url = 'http://192.168.57.75:18490/oracle_view';
                } else {
                    url = `${this.BACKEND_API}/oracle_view`;
                }
                this.$axios
                    .get(url, { params: { project_name: projectName } })
                    .then((res) => {
                        if (res.data === {}) {
                            console.log('data is empty');
                            resolve(404);
                        }
                        this.form.canEditProjectDirector = false;
                        this.form.process_compliance = res.data.lcfhd;
                        this.form.created_at = res.data.lxrq;
                        this.form.project_summary = res.data.xmgy.replace(/\&nbsp;/g," ",).replace(/<br>/g,'\n').replace(/<br>\//g,'\n').replace(/<br> \//g,'\n');
                        if (res.data.xmjsrq) {
                            this.form.init_project_start_date = res.data.xmksrq;
                            this.form.project_start_date = res.data.xmksrq;
                        }
                        if (res.data.xmjsrq) {
                            let start = new Date(res.data.xmksrq);
                            let end = new Date(res.data.xmjsrq);
                            this.form.init_project_end_date = res.data.xmjsrq;
                            this.form.project_end_date = res.data.xmjsrq;
                            const duration = end.getTime() - start.getTime();
                            const monthDuration =
                                duration / (24 * 60 * 60 * 30 * 1000);
                            let projectPeriod =
                                Math.floor(monthDuration * 10) / 10;
                            this.projectPeriod = projectPeriod;
                            this.form.project_period = projectPeriod;
                        }
                        this.form.defect_density = res.data.qgcqxmd;
                        this.form.software_platform = Number(res.data.rjpt);
                        this.form.software_version = res.data.rjptbb == 'None' ? '' : res.data.rjptbb;
                        // this.form.business_group_id = res.data.sssyq;
                        this.form.project_level = res.data.xmjb;
                        this.form.project_manager_id = res.data.xmjl;
                        this.form.sales_id = res.data.xsry;
                        this.form.entire_subcontract = res.data.sfztzb1 === 3;
                        this.form.is_pre_dev = res.data.sfyyxm === 0;
                        this.form.income_check_method = Number(res.data.srqrfsxml);
                        this.form.security_level = res.data.xxaqjb == 'None' ? '' : res.data.xxaqjb;
                        this.form.one_time_release_success_rate =
                            res.data.rjycffbcgl;
                        this.form.hardware_version = res.data.yjptbb  == 'None' ? '' : res.data.yjptbb;
                        this.form.hardware_platform =  Number(res.data.yjptnew);
                        this.form.est_market_size_over_20_million =
                            res.data.yjscgm;
                        // this.profit_rate = res.data.yjmll1
                        // this.estIncome = res.data.yjzsrrmb1
                        // this.estIncomeRaw = res.data.yjzsryb1
                        // this.estCost = res.data.yjztrrmb1
                        this.form.currency_id = parseInt(res.data.bz1);
                        this.form.currency = parseFloat(res.data.zshl).toFixed(
                            6
                        );
                        this.form.business_type = [
                            res.data.ywlx.toString(),
                            res.data.ywlxxf.toString()
                        ];
                        this.form.product_category = [
                            getProductionCategory(res.data.cplx),
                            res.data.cplx.toString(),
                        ];
                        // 拉取工时状态
                        this.form.workhour_status = res.data.gszt || '';
                        this.form.billing_period = res.data.zq == 'None' ? '' : res.data.zq;
                        this.form.hardware_revision_count = res.data.yjgbcsnew;
                        this.form.sales = res.data.xsryxm == 'None' ? '' : res.data.xsryxm
                        this.form.customer_full_name = res.data.khqc == 'None' ? '' : res.data.khqc;
                        this.form.customer_region = res.data.khdz == 'None' ? '' : res.data.khdz;
                        this.form.corporation = res.data.gsqc == 'None' ? '' : res.data.gsqc;
                        this.form.product = res.data.zjscpzxm;
                        this.loading = false;
                        resolve(res.data);
                    })
                    .catch((err) => {
                        reject(err);
                    });
            });
        },
        async handleProjectNameChanged(projectId) {
            if (this.mode === 'change') {
                // 创建新表单或获取草稿表单
                this.loading = true;
                let changeData = await this.requestChangeProject(projectId);
                this.form.project_id = projectId;
                await this.loadProjectProperties(changeData.project_name)
                    // 重新拉取立项事业部信息
                    .then((data) => {
                        return new Promise((resolve, reject) => {
                            const url = `${process.env.VUE_APP_PROJECT_REQUEST_HOST}/api/base/department/${data.lxsyb}`;
                            this.$axios.get(url).then((response) => {
                                if (response.data.code === 200) {
                                    this.form.business_department =
                                        response.data.data.name;
                                    this.form.business_department_id =
                                        response.data.data.id;
                                    this.form.business_department_manager =
                                        response.data.data.manager;
                                    this.form.business_group =
                                        response.data.data.business_group.name;
                                    this.form.business_group_id =
                                        response.data.data.business_group.id;
                                    this.form.business_group_manager =
                                        response.data.data.business_group.manager;
                                    let incomeDistribution =
                                        this.form.incomeDistribution || [];
                                    if (incomeDistribution.length) {
                                        incomeDistribution[0].manager_id =
                                            this.form.project_manager_id
										incomeDistribution[0].manager =
											this.form.project_manager
                                        incomeDistribution[0].implement_department_id =
                                            response.data.data.id;
										incomeDistribution[0].implement_department =
											response.data.data.name;
                                    }
                                    resolve({ data: data });
                                }
                            });
                        });
                    })
                    .then((data) => {
                        return new Promise((resolve, reject) => {
                            let data = {
                                //因为汇率原因，总投入，毛利，毛利率3个字段无法实时显示， 建议废除这三个字段，直接使用公式展示
                                form: this.form,
                                form_old: this.oldForm,
                                calculated: this.getCalculated(),
                                calculated_old: this.oldCalculated,
                            };
                            this.formSave(data).then((res) => {
                                this.$router.push({
                                    name: 'edit',
                                    params: { id: res.data.data.form_id },
                                });
                            });
                        });
                    });
            } else if (
                this.canEdit &&
                this.project_name_save === this.form.project_name
            ) {
                this.projectIcon = 'el-icon-check';
            } else {
                let projectName = this.form.project_name;
                this.form.project_name = projectName.replace(/[^A-Za-z0-9_]/g,'');
                let PnStart = projectName.indexOf("Pre_");
                if(PnStart == 0){
                    this.form.is_pre_dev = true ;
                    let namePre = projectName.replace("Pre_","");
                    this.$axios
                    .get(
                        `${this.BACKEND_API}/api/base/project/exist?project_name=${namePre}`
                    )
                    .then(response => {
                        if (this.form.project_name === '') {
                            this.projectIcon = 'el-icon-more';
                        } else if (response.data.exist === true) {
                            this.$message.error(`项目${namePre}已存在，请使用其它项目名`);
                            this.form.project_name = '';
                            this.projectIcon = 'el-icon-close';
                        } else {
                            this.judgmentProjectName(this.form.project_name)
                            setTimeout(() =>{
                                this.$message.success('已默认为预研项目');
                            },2000);
                        }
                    })
                    .catch(error => {
                        console.log(error);
                    });
                    return false
                }else if(PnStart == -1){
                    this.form.is_pre_dev = false ; 
                    let namePre2 = `Pre_${projectName}`
                    this.$axios
                    .get(
                        `${this.BACKEND_API}/api/base/project/exist?project_name=${namePre2}`
                    )
                    .then(response => {
                        if (this.form.project_name === '') {
                            this.projectIcon = 'el-icon-more';
                        } else if (response.data.exist === true) {
                            this.preResearchProject(namePre2);
                        } else {
                            this.judgmentProjectName(this.form.project_name);
                            setTimeout(() =>{
                                this.$message.success('已默认为非预研项目');
                            },2000);
                        }
                    })
                    .catch(error => {
                        console.log(error);
                    });
                }
            }
        },
        preResearchProject(name) {
            this.$confirm(`是否是${name}的正式项目`, '提示', {
                confirmButtonText: '是',
                cancelButtonText: '否',
                type: 'warning'
            })
            .then(() => {
                this.projectIcon = 'el-icon-check';
                this.judgmentProjectName(this.form.project_name);
                setTimeout(() =>{
                    this.$message.success('已默认为非预研项目');
                },2000);
            }).catch(() => {
                this.form.project_name = '';
                this.projectIcon = 'el-icon-close';
                this.message('不可创建', 'error');       
            });
        },
        judgmentProjectName(ProjectName){
            this.$axios
            .get(
                `${this.BACKEND_API}/api/base/project/exist?project_name=${ProjectName}`
            )
            .then(response => {
                if (this.form.project_name === '') {
                    this.projectIcon = 'el-icon-more';
                } else if (response.data.exist === true) {
                    this.$message.error('项目已存在，请使用其它项目名');
                    this.form.project_name = '';
                    this.projectIcon = 'el-icon-close';
                } else {
                    this.projectIcon = 'el-icon-check';
                    this.submitForm();
                }
            })
            .catch(error => {
                console.log(error);
            });
        },
        handleSelectCurrency(item) {
            this.exchangeRate.map((v) => {
                if (v.id == item) {
                    this.form.currency = v.rate.toFixed(6);
                }
            });
            this.calculateTotalManMonth();
            this.calculateTotalIncome();
        },
        handleSelectSales(item) {
            this.form.sales_id = item.id;
        },
        handleSelectBusinessDepartment(item) {
            this.form.implement_department = item.id;
        },
        handleSelectProjectManager(item) {
            this.form.project_manager_id = item.id;
            this.form.project_manager_name = item.name;
            this.form.project_manager = item.name;
            if(this.ldap != item.ldap){
                this.$confirm('此操作将修改项目经理，修改成功后，您将不可再编辑此项目，是否继续?', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    return new Promise ((resolve,reject)=>{
                        this.submitForm();
                        resolve();
                    }).then(()=>{
                        setTimeout(() =>{
                            this.$router.push({
                                name: 'view',
                                params: { id: this.$route.params.id },
                            });
                        },500)
                        this.message('修改成功', 'success');
                    })
                }).catch(() => {
                    this.form.project_manager_id = '';
                    this.form.project_manager_name = '';
                    this.form.project_manager = '';
                    this.message('取消修改，请重新填写项目经理', 'warning');
                });
            }
        },
        handleSelectPreProjectName(item) {
            this.form.pre_project_name = item.name;
            this.form.pre_project_id = item.id;
        },
        handleSelectProjectDirector(item) {
            this.form.project_director_id = item.id;
        },
        handleSelectCorporation(item) {
            this.form.corporation_id = item.id;
        },
        handleDepartmentChanged(item) {
            // 清空部门相关表单
            if (typeof item.name != 'undefined' && item.name === '') {
                this.form.business_department_manager = '';
                this.form.business_department = '';
            }
        },
        handleSelectImplementDepartment(item) {
            this.form.incomeDistributionSubmit[item.value] = item.id;
        },
        async handleSelectImplementDepartmentDistribution(item, row) {
            let index = this.form.incomeDistribution.indexOf(row);
            if (
                this.form.incomeDistribution.find(
                    (x) => x.implement_department_id === item.id
                )
            ) {
                this.form.incomeDistribution[index].implement_department = '';
                this.form.incomeDistribution[index].implement_department_id = '',
                this.form.incomeDistribution[index].sub_project_name = '';
                this.form.incomeDistribution[index].abbr_name = '';
                this.$message.warning('请勿选择重复的部门');
                return;
            }
            this.form.incomeDistribution[index].abbr_name = item.abbr_name;
            this.form.incomeDistribution[index].implement_department_id =
                item.id;
            if(this.form.incomeDistribution[index].implement_department_id == undefined){
                this.form.incomeDistribution[index].implement_department = '';
                let obj = 'implement_department_id';
                this.form.incomeDistribution[index][obj] = '';
            }
            // 生成子项目名称并获取是否存在
            const subProjectName =
                item.implement_department === this.form.business_department
                    ? this.form.project_name
                    : `Sub_${this.form.project_name}_${item.abbr_name}`;
            this.form.incomeDistribution[
                index
            ].sub_project_name = subProjectName;
            await this.getSubProjectId(subProjectName).then((data) => {
                this.form.incomeDistribution[index].sub_project_id = data.id;
            });
            // 计算
            this.calculateTotalManMonth();
        },
        implement_department_change(row) {
            let index = this.form.incomeDistribution.indexOf(row);
            this.form.incomeDistribution[index].implement_department = '';
            this.form.incomeDistribution[index].implement_department_id = '';
            this.form.incomeDistribution[index].sub_project_name = '';
            this.form.incomeDistribution[index].abbr_name = '';
        },
        handleSelectManagerDistribution(item, row) {
            let index = this.form.incomeDistribution.indexOf(row);
            this.form.incomeDistribution[index].manager_id = item.id;
            this.form.incomeDistribution[index].isValid = true;
        },
        clearSelectManagerDistribution(row) {
            let index = this.form.incomeDistribution.indexOf(row);
            this.form.incomeDistribution[index].manager_id = '';
            this.form.incomeDistribution[index].manager = '';
        },
        customerLevel() {
            if (this.form.customer_level === '0') {
                for (let i in this.form.customerMsg) {
                    this.form.customerMsg[i].clause_Small =
                        '首付比例不低于30%，尾款不高于30%';
                    this.form.customerMsg[i].clause_Large =
                        '首付比例不低于30%，尾款不高于30%';
                    this.form.customerMsg[i].investment =
                        '立项通过即可按计划投入';
                }
            } else if (this.form.customer_level === '1') {
                for (let i in this.form.customerMsg) {
                    this.form.customerMsg[i].clause_Small =
                        '1.预付款>60%，或预付款能覆盖受案时点已投入的项目成本\n2.不留尾款，或客户违约不支付尾款也能达成公司利润率要求';
                    this.form.customerMsg[i].clause_Large = '收款比例3:3:3:1';
                    this.form.customerMsg[i].investment =
                        '立项通过合同签订前，投入不允许超过总工时10%';
                }
            } else if (this.form.customer_level === '2') {
                for (let i in this.form.customerMsg) {
                    this.form.customerMsg[i].clause_Small =
                        '1.预付款>60%，或预付款能覆盖受案时点已投入的项目成本\n2.不留尾款，或客户违约不支付尾款也能达成公司利润率要求';
                    this.form.customerMsg[i].clause_Large = '收款比例5:2:2:1:0';
                    this.form.customerMsg[i].investment =
                        '立项通过且合同签订，方允许投入';
                }
            } else if (
                this.form.customer_level === '3' ||
                this.form.customer_level === '4'
            ) {
                for (let i in this.form.customerMsg) {
                    this.form.customerMsg[i].clause_Small =
                        '1.预付款>60%，或预付款能覆盖受案时点已投入的项目成本\n2.不留尾款，或客户违约不支付尾款也能达成公司利润率要求';
                    this.form.customerMsg[i].clause_Large = '首款比例6:2:1:1:0';
                    this.form.customerMsg[i].investment =
                        '立项前销售需要提供客户有支付能力的证据，事业群总裁进行客户审批后方可立项';
                }
            }
        },
        handleSelectCustomer(customer) {
            this.form.customer_abrv_name = customer.abbr_name;
            this.form.customer_level = customer.level;
            this.form.customer_category = customer.category;
            this.form.customer_region = customer.region;
            this.form.customer_region_id = customer.region_id;
            this.form.customer_id = customer.id;
            this.customerLevel();
        },
        handleSelectDepartment(item) {
            this.form.business_department_id = item.id;
            this.form.business_department_manager = item.manager;
            this.form.implement_department_id = item.id;
            // 添加收入拆分
            this.addIncomeDistributionRow(item.name);
            this.form.incomeDistribution[0].canDelete = false;
            this.form.incomeDistribution[0].implement_department_id = item.id;
            this.form.incomeDistribution[0].sub_project_name = this.form.project_name;
            // 设置工时管理员为PM
            this.form.incomeDistribution[0].manager_id = this.form.project_manager_id;
            this.$axios
                .get(
                    `${this.BACKEND_API}/api/base/business_group/search?department_id=${item.id}`
                )
                .then((response) => {
                    this.form.business_group_manager =
                        response.data.data.manager;
                    this.form.business_group = response.data.data.name;
                    this.form.business_group_id = response.data.data.id;
                });
        },
        handleBusinessTypeChange(businessType) {
            switch (businessType[1]) {
                case '0':
                    this.incomeCheckMethods = [
                        { label: '履约进度法', value: 9 },
                        { label: '结算单', value: 10 },
                    ];
                    break;
                case '23':
                    this.incomeCheckMethods = [
                        { label: '履约进度法', value: 9 },
                    ];
                    break;
                case '8':
                    this.incomeCheckMethods = [
                        { label: '履约进度法', value: 9 },
                    ];
                    break;
                case '11':
                    this.incomeCheckMethods = [
                        { label: '履约进度法', value: 9 },
                        { label: '结算单', value: 10 },
                    ];
                    break;
                case '12':
                    this.incomeCheckMethods = [
                        { label: '履约进度法', value: 9 },
                        { label: '结算单', value: 10 },
                        { label: '商品销售法', value: 11 },
                        { label: '无收入', value: 12 },
                    ];
                    break;
                case '17':
                    this.incomeCheckMethods = [{ label: '结算单', value: 10 }];
                    break;
                case '18':
                    this.incomeCheckMethods = [{ label: '结算单', value: 10 }];
                    break;
                case '19':
                    this.incomeCheckMethods = [
                        { label: '商品销售法', value: 11 },
                    ];
                    break;
                case '20':
                    this.incomeCheckMethods = [
                        { label: '商品销售法', value: 11 },
                    ];
                    break;
                case '21':
                    this.incomeCheckMethods = [
                        { label: '商品销售法', value: 11 },
                    ];
                    break;
                case '2':
                    this.incomeCheckMethods = [{ label: '结算单', value: 10 }];
                    break;
                case '22':
                    this.incomeCheckMethods = [
                        { label: '履约进度法', value: 9 },
                    ];
                    break;
                default:
                    this.incomeCheckMethods = [];
                    break;
            }
            this.form.income_check_method = '';
        },
        projectStartDateFocus(time){
            this.lastStartTime = time;
        },
        projectStartDateChanged(){
            if (this.form.project_start_date && this.form.project_end_date) {
                console.log('valid dates');
                console.log('requestType', this.requestType);
                const end = new Date(this.form.project_end_date);
                let start = new Date(
                    this.form.project_start_date.toString().replace(/-/g, '/')
                );
                const duration = end.getTime() - start.getTime();
                const monthDuration = duration / (24 * 60 * 60 * 30 * 1000);
                let projectPeriod = Math.floor(monthDuration * 10) / 10;
                this.projectPeriod = projectPeriod;
                this.form.project_period = projectPeriod;
                // get past month list
                if (
                    this.mode === 'edit' ||
                    this.mode === 'change' ||
                    this.mode === 'create'
                ) {
                    this.changTime(this.form.project_name).then(currentDate=>{
                        let { pastMonths, nextMonths } = getProjectPeriods(
                            start,
                            end,
                            this.requestType === 1,
                            currentDate
                        );
                        this.form.pastMonths = pastMonths;
                        this.form.nextMonths = nextMonths;
                        this.form.allMonths = pastMonths.concat(nextMonths);
                        this.form.manPowerOutSourcingInput.forEach(item => {
                            if(this.form.allMonths.length > item.input.length){
                            // 修改工数预测数据外包人力
                                item.input = new Array(
                                        this.form.allMonths.length - item.input.length
                                    ).fill(0).concat(item.input) 
                                // 修改工数预测数据公司人力
                                if(this.requestType === 1){
                                    this.form.historyManPowerInput.forEach(v =>{
                                        v.input = 
                                        new Array(
                                            this.form.pastMonths.length - v.input.length
                                        ).fill(0)
                                        .concat(v.input)
                                    })
                                }else{
                                    this.form.manPowerInput.forEach(v => {
                                        v.input = 
                                            new Array(
                                                this.form.nextMonths.length - v.input.length
                                            ).fill(0)
                                            .concat(v.input)
                                    });
                                }
                                // 修改项目收入
                                this.form.projectIncome.forEach(v => {
                                    v.input = 
                                        new Array(
                                            this.form.allMonths.length - v.input.length
                                        ).fill(0)
                                        .concat(v.input)
                                });
                                
                                // 修改采购成本/商品销售成本
                                this.form.purchaseCost.forEach(v =>{
                                    v.input = 
                                        new Array(
                                            this.form.allMonths.length - v.input.length
                                        ).fill(0)
                                        .concat(v.input)
                                });
                                // 修改生产成本/商品销售成本
                                this.form.productionCost.forEach(v =>{
                                    v.input = 
                                        new Array(
                                            this.form.allMonths.length - v.input.length
                                        ).fill(0)
                                        .concat(v.input)
                                });
                                // 修改外包成本
                                this.form.outsourcingProjectCost.forEach(v =>{
                                    v.input = 
                                        new Array(
                                            this.form.allMonths.length - v.input.length
                                        ).fill(0)
                                        .concat(v.input)
                                });
                                // 修改其他人力
                                this.form.labourOtherCost.forEach(v =>{
                                    v.input = 
                                        new Array(
                                            this.form.allMonths.length - v.input.length
                                        ).fill(0)
                                        .concat(v.input)
                                });
                                // 修改国内差旅
                                this.form.domesticTravel.forEach(v =>{
                                    v.input = 
                                        new Array(
                                            this.form.allMonths.length - v.input.length
                                        ).fill(0)
                                        .concat(v.input)
                                });
                                // 修改国际差旅
                                this.form.foreignTravel.forEach(v =>{
                                    v.input = 
                                        new Array(
                                            this.form.allMonths.length - v.input.length
                                        ).fill(0)
                                        .concat(v.input)
                                });
                                // 修改租赁费用
                                this.form.rent.forEach(v =>{
                                    v.input = 
                                        new Array(
                                            this.form.allMonths.length - v.input.length
                                        ).fill(0)
                                        .concat(v.input)
                                });
                                // 修改运营支出
                                this.form.operation.forEach(v =>{
                                    v.input = 
                                        new Array(
                                            this.form.allMonths.length - v.input.length
                                        ).fill(0)
                                        .concat(v.input)
                                });
                                // 修改IT支出
                                this.form.it_cost.forEach(v => {
                                    v.input = 
                                        new Array(
                                            this.form.allMonths.length - v.input.length
                                        ).fill(0)
                                        .concat(v.input)
                                });
                                // 修改折旧摊销
                                this.form.depreciation.forEach(v => {
                                    v.input = 
                                        new Array(
                                            this.form.allMonths.length - v.input.length
                                        ).fill(0)
                                        .concat(v.input)
                                });
                                // 修改固定资产
                                this.form.assets.forEach(v => {
                                    v.input = 
                                        new Array(
                                            this.form.allMonths.length - v.input.length
                                        ).fill(0)
                                        .concat(v.input)
                                });
                                // 修改无形资产
                                this.form.immaterial.forEach(v => {
                                v.input = 
                                        new Array(
                                            this.form.allMonths.length - v.input.length
                                        ).fill(0)
                                        .concat(v.input)
                                });
                            }else if(this.form.allMonths.length < item.input.length){
                                this.projectStartDateOpen();
                            }
                        });
                    });
                     // 重新计算人力成本
                    this.calculateTotalManMonth();
                    // if (this.requestType === 1) {
                    //     let newHistoryLabourInput = initHistoryLabourInput(
                    //         pastMonths.length
                    //     );
                    //     this.form.historyManPowerInput = newHistoryLabourInput;
                    // }
                }
            }
        },
        projectStartDateOpen(){
            this.$confirm('此操作将缩短项目周期,是否继续?', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
            }).then(() => {
                // 修改项目收入 
                this.form.projectIncome.forEach(item =>{
                    item.input.splice(0, 
                        item.input.length - this.form.allMonths.length
                    );
                });
                // 修改工数预测数据公司人力
                if(this.form.historyManPowerInput){
                    this.form.historyManPowerInput.forEach(item =>{
                        item.input.splice(0, 
                            item.input.length - this.form.pastMonths.length
                        );
                    });
                    this.form.manPowerInput.forEach(item =>{
                        item.input.splice(0, 
                            item.input.length - this.form.nextMonths.length
                        );
                    });
                }else{
                    this.form.manPowerInput.forEach(item =>{
                        item.input.splice(0, 
                            item.input.length - this.form.nextMonths.length
                        );
                    });
                };
                // 修改工数预测数据外包人力
                this.form.manPowerOutSourcingInput.forEach(item =>{
                    item.input.splice(0, 
                        item.input.length - this.form.allMonths.length
                    );
                });
                // 修改采购成本/商品销售成本
                this.form.purchaseCost.forEach(item =>{
                    item.input.splice(0, 
                        item.input.length - this.form.allMonths.length
                    );
                });
                // 修改生产成本/商品销售成本
                this.form.productionCost.forEach(item =>{
                    item.input.splice(0, 
                        item.input.length - this.form.allMonths.length
                    );
                });
                // 修改外包成本
                this.form.outsourcingProjectCost.forEach(item =>{
                    item.input.splice(0, 
                        item.input.length - this.form.allMonths.length
                    );
                });
                // 修改其他人力
                this.form.labourOtherCost.forEach(item =>{
                    item.input.splice(0, 
                        item.input.length - this.form.allMonths.length
                    );
                });
                // 修改国内差旅
                this.form.domesticTravel.forEach(item =>{
                    item.input.splice(0, 
                        item.input.length - this.form.allMonths.length
                    );
                });
                // 修改国际差旅
                this.form.foreignTravel.forEach(item =>{
                    item.input.splice(0, 
                        item.input.length - this.form.allMonths.length
                    );
                });
                // 修改租赁费用
                this.form.rent.forEach(item =>{
                    item.input.splice(0, 
                        item.input.length - this.form.allMonths.length
                    );
                });
                // 修改运营支出
                this.form.operation.forEach(item =>{
                    item.input.splice(0, 
                        item.input.length - this.form.allMonths.length
                    );
                });
                // 修改IT支出
                this.form.it_cost.forEach(item => {
                    item.input.splice(0, 
                        item.input.length - this.form.allMonths.length
                    );
                });
                // 修改折旧摊销
                this.form.depreciation.forEach(item => {
                    item.input.splice(0, 
                        item.input.length - this.form.allMonths.length
                    );
                });
                // 修改固定资产
                this.form.assets.forEach(item => {
                    item.input.splice(0, 
                        item.input.length - this.form.allMonths.length
                    );
                });
                // 修改无形资产
                this.form.immaterial.forEach(item => {
                    item.input.splice(0, 
                        item.input.length - this.form.allMonths.length
                    );
                });
                // 重新计算人力成本
                this.calculateTotalManMonth();
            }).catch(() => {
                this.form.project_start_date = this.lastStartTime;
                const end = new Date(this.form.project_end_date);
                let start = new Date(
                    this.form.project_start_date.toString().replace(/-/g, '/')
                );
                const duration = end.getTime() - start.getTime();
                const monthDuration = duration / (24 * 60 * 60 * 30 * 1000);
                let projectPeriod = Math.floor(monthDuration * 10) / 10;
                this.projectPeriod = projectPeriod;
                this.form.project_period = projectPeriod;
                this.changTime(this.form.project_name).then(currentDate=>{
                    let { pastMonths, nextMonths } = getProjectPeriods(
                        start,
                        end,
                        this.requestType === 1,
                        currentDate
                    );
                    this.form.pastMonths = pastMonths;
                    this.form.nextMonths = nextMonths;
                    this.form.allMonths = pastMonths.concat(nextMonths);
                });
                // 重新计算人力成本
                this.calculateTotalManMonth();
            });
        },
        projectEndDateFocus(time){
            this.lastEndTime = time;
        },
        projectEndDateChanged() {
            if (this.form.project_start_date && this.form.project_end_date) {
                console.log('valid dates');
                console.log('requestType', this.requestType);
                const end = new Date(this.form.project_end_date);
                let start = new Date(
                    this.form.project_start_date.toString().replace(/-/g, '/')
                );
                const duration = end.getTime() - start.getTime();
                const monthDuration = duration / (24 * 60 * 60 * 30 * 1000);
                let projectPeriod = Math.floor(monthDuration * 10) / 10;
                this.projectPeriod = projectPeriod;
                this.form.project_period = projectPeriod;
                // get past month list
                if (
                    this.mode === 'edit' ||
                    this.mode === 'change' ||
                    this.mode === 'create'
                ) {
                    this.changTime(this.form.project_name).then(currentDate=>{
                        let { pastMonths, nextMonths } = getProjectPeriods(
                            start,
                            end,
                            this.requestType === 1,
                            currentDate
                        );
                        this.form.pastMonths = pastMonths;
                        this.form.nextMonths = nextMonths;
                        this.form.allMonths = pastMonths.concat(nextMonths);
                        // 修改项目收入
                        this.form.projectIncome.forEach(item => {
                            if(this.form.allMonths.length > item.input.length){
                                item.input = item.input.concat(
                                    new Array(
                                        this.form.allMonths.length - item.input.length
                                    ).fill(0)
                                );
                                // 修改工数预测数据公司人力
                                this.form.manPowerInput.forEach(v => {
                                    v.input = v.input.concat(
                                        new Array(
                                            this.form.nextMonths.length - v.input.length
                                        ).fill(0)
                                    );
                                });
                                // 修改工数预测数据外包人力
                                this.form.manPowerOutSourcingInput.forEach(v => {
                                    v.input = v.input.concat(
                                        new Array(
                                            this.form.allMonths.length - v.input.length
                                        ).fill(0)
                                    );
                                });
                                // 修改采购成本/商品销售成本
                                this.form.purchaseCost.forEach(v =>{
                                    v.input = v.input.concat(
                                        new Array(
                                            this.form.allMonths.length - v.input.length
                                        ).fill(0)
                                    );
                                });
                                // 修改生产成本/商品销售成本
                                this.form.productionCost.forEach(v =>{
                                    v.input = v.input.concat(
                                        new Array(
                                            this.form.allMonths.length - v.input.length
                                        ).fill(0)
                                    );
                                });
                                // 修改外包成本
                                this.form.outsourcingProjectCost.forEach(v =>{
                                    v.input = v.input.concat(
                                        new Array(
                                            this.form.allMonths.length - v.input.length
                                        ).fill(0)
                                    );
                                });
                                // 修改其他人力
                                this.form.labourOtherCost.forEach(v =>{
                                    v.input = v.input.concat(
                                        new Array(
                                            this.form.allMonths.length - v.input.length
                                        ).fill(0)
                                    );
                                });
                                // 修改国内差旅
                                this.form.domesticTravel.forEach(v =>{
                                    v.input = v.input.concat(
                                        new Array(
                                            this.form.allMonths.length - v.input.length
                                        ).fill(0)
                                    );
                                });
                                // 修改国际差旅
                                this.form.foreignTravel.forEach(v =>{
                                    v.input = v.input.concat(
                                        new Array(
                                            this.form.allMonths.length - v.input.length
                                        ).fill(0)
                                    );
                                });
                                // 修改租赁费用
                                this.form.rent.forEach(v =>{
                                    v.input = v.input.concat(
                                        new Array(
                                            this.form.allMonths.length - v.input.length
                                        ).fill(0)
                                    );
                                });
                                // 修改运营支出
                                this.form.operation.forEach(v =>{
                                    v.input = v.input.concat(
                                        new Array(
                                            this.form.allMonths.length - v.input.length
                                        ).fill(0)
                                    );
                                });
                                // 修改IT支出
                                this.form.it_cost.forEach(v => {
                                    v.input = v.input.concat(
                                        new Array(
                                            this.form.allMonths.length - v.input.length
                                        ).fill(0)
                                    );
                                });
                                // 修改折旧摊销
                                this.form.depreciation.forEach(v => {
                                    v.input = v.input.concat(
                                        new Array(
                                            this.form.allMonths.length - v.input.length
                                        ).fill(0)
                                    );
                                });
                                // 修改固定资产
                                this.form.assets.forEach(v => {
                                    v.input = v.input.concat(
                                        new Array(
                                            this.form.allMonths.length - v.input.length
                                        ).fill(0)
                                    );
                                });
                                // 修改无形资产
                                this.form.immaterial.forEach(v => {
                                v.input = v.input.concat(
                                        new Array(
                                            this.form.allMonths.length - v.input.length
                                        ).fill(0)
                                    );
                                });
                            }else if(this.form.allMonths.length < item.input.length){
                                if(this.mode === 'edit'){
                                    this.projectEndDateOpen();
                                }
                            }
                        });
                    });
                    // 重新计算人力成本
                    this.calculateTotalManMonth();
                    // if (this.requestType === 1) {
                    //     let newHistoryLabourInput = initHistoryLabourInput(
                    //         pastMonths.length
                    //     );
                    //     this.form.historyManPowerInput = newHistoryLabourInput;
                    // }
                } 
            }
        },
        projectEndDateOpen(){
            this.$confirm('此操作将缩短项目周期,是否继续?', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
            }).then(() => {
                // 修改项目收入
                this.form.projectIncome.forEach(item =>{
                    item.input =item.input.splice(0, 
                        item.input.length - (
                            item.input.length - this.form.allMonths.length
                            )   
                        );
                });
                // 修改工数预测数据公司人力
                this.form.manPowerInput.forEach(item =>{
                    item.input =item.input.splice(0, 
                        item.input.length - (
                            item.input.length - this.form.nextMonths.length
                            )   
                        );
                });
                // 修改工数预测数据外包人力
                this.form.manPowerOutSourcingInput.forEach(item =>{
                    item.input =item.input.splice(0, 
                        item.input.length - (
                            item.input.length - this.form.allMonths.length
                            )   
                        );
                });
                // 修改采购成本/商品销售成本
                this.form.purchaseCost.forEach(item =>{
                    item.input =item.input.splice(0, 
                        item.input.length - (
                            item.input.length - this.form.allMonths.length
                            )   
                        );
                });
                // 修改生产成本/商品销售成本
                this.form.productionCost.forEach(item =>{
                    item.input =item.input.splice(0, 
                        item.input.length - (
                            item.input.length - this.form.allMonths.length
                            )   
                        );
                });
                // 修改外包成本
                this.form.outsourcingProjectCost.forEach(item =>{
                    item.input =item.input.splice(0, 
                        item.input.length - (
                            item.input.length - this.form.allMonths.length
                            )   
                        );
                });
                // 修改其他人力
                this.form.labourOtherCost.forEach(item =>{
                    item.input =item.input.splice(0, 
                        item.input.length - (
                            item.input.length - this.form.allMonths.length
                            )   
                        );
                });
                // 修改国内差旅
                this.form.domesticTravel.forEach(item =>{
                    item.input =item.input.splice(0, 
                        item.input.length - (
                            item.input.length - this.form.allMonths.length
                            )   
                        );
                });
                // 修改国际差旅
                this.form.foreignTravel.forEach(item =>{
                    item.input =item.input.splice(0, 
                        item.input.length - (
                            item.input.length - this.form.allMonths.length
                            )   
                        );
                });
                // 修改租赁费用
                this.form.rent.forEach(item =>{
                    item.input =item.input.splice(0, 
                        item.input.length - (
                            item.input.length - this.form.allMonths.length
                            )   
                        );
                });
                // 修改运营支出
                this.form.operation.forEach(item =>{
                    item.input =item.input.splice(0, 
                        item.input.length - (
                            item.input.length - this.form.allMonths.length
                            )   
                        );
                });
                // 修改IT支出
                this.form.it_cost.forEach(item => {
                    item.input =item.input.splice(0, 
                        item.input.length - (
                            item.input.length - this.form.allMonths.length
                            )   
                        );
                });
                // 修改折旧摊销
                this.form.depreciation.forEach(item => {
                    item.input =item.input.splice(0, 
                        item.input.length - (
                            item.input.length - this.form.allMonths.length
                            )   
                        );
                });
                // 修改固定资产
                this.form.assets.forEach(item => {
                    item.input =item.input.splice(0, 
                        item.input.length - (
                            item.input.length - this.form.allMonths.length
                            )   
                        );
                });
                // 修改无形资产
                this.form.immaterial.forEach(item => {
                    item.input =item.input.splice(0, 
                        item.input.length - (
                            item.input.length - this.form.allMonths.length
                            )   
                        );
                });
                // 重新计算人力成本
                this.calculateTotalManMonth();
            }).catch(() => {
                this.form.project_end_date = this.lastEndTime;
                const end = new Date(this.form.project_end_date);
                let start = new Date(
                    this.form.project_start_date.toString().replace(/-/g, '/')
                );
                const duration = end.getTime() - start.getTime();
                const monthDuration = duration / (24 * 60 * 60 * 30 * 1000);
                let projectPeriod = Math.floor(monthDuration * 10) / 10;
                this.projectPeriod = projectPeriod;
                this.form.project_period = projectPeriod;
                this.changTime(this.form.project_name).then(currentDate=>{
                    let { pastMonths, nextMonths } = getProjectPeriods(
                        start,
                        end,
                        this.requestType === 1,
                        currentDate
                    );
                    this.form.pastMonths = pastMonths;
                    this.form.nextMonths = nextMonths;
                    this.form.allMonths = pastMonths.concat(nextMonths);
                });
                // 重新计算人力成本
                this.calculateTotalManMonth();
            });
        },
        estLabourMonth() {
            const months = [];
            let start = new Date(this.form.project_start_date);
            if (this.requestType === 1) {
                start = new Date();
            }
            const end = new Date(this.form.project_end_date);
            let monthCount = 0;
            let currYear = start.getFullYear();
            let currMonth = start.getMonth();
            monthCount = (end.getFullYear() - start.getFullYear()) * 12;
            monthCount -= start.getMonth();
            monthCount += end.getMonth();
            for (let i = 0; i < monthCount + 1; i++) {
                if (currMonth < 12) {
                    currMonth += 1;
                } else {
                    currYear += 1;
                    currMonth = 1;
                }
                months.push(`${currYear}年${currMonth}月`);
            }
            return months;
        },
        calculateQuotation(row, index, rowIndex) {
            let projectIncome = this.form.projectIncome;
            if (row.field === 'nre_offer_man_month') {
                let sum =
                    parseFloat(projectIncome[0].input[index]) *
                    parseFloat(projectIncome[1].value);
                this.form.projectIncome[2].input[index] = sum;
                this.form.projectIncome[3].input[index] = sum;
            } else if (row.field === 'nre_offer_per_unit') {
                this.form.projectIncome[0].input.map((item, ind) => {
                    let sum =
                        parseFloat(item) * parseFloat(projectIncome[1].value);
                    this.form.projectIncome[2].input[ind] = sum;
                    this.form.projectIncome[3].input[ind] = sum;
                });
            } else if (row.type == 'input' && row.input_type == 1) {
                let incomeRMB = parseFloat(row.input[index]);
                this.form.projectIncome[rowIndex + 1].input[index] = incomeRMB;
            }
            this.calculateTotalManMonth();
            this.calculateTotalIncome();
            this.calculateDepreciation();
            this.calculateLabourCost();
        },
        calculateTravel() {
            // 计算总投入
            this.calculateTotalCost();
            this.profit = this.estIncomeRaw * this.form.currency - this.estCost;
            if (this.estCost) {
                this.profit_rate =
                    ((this.estIncomeRaw * this.form.currency - this.estCost) *
                        100) /
                    (this.estIncomeRaw * this.form.currency);
            }
            if (this.totalManMonth && this.totalManMonth != 0) {
                this.avgCostRMB = this.estCost / this.totalManMonth;
            }
        },
        calculateTabTotal(type) {
            //财务预测小计
            let list = this.form[type];
            let tabTotal = 0;
            let addtionCost = this.form.labourOtherCost[0].input.reduce(
                (a, b) => parseFloat(a || '0') + parseFloat(b || '0'),
                0
            );
            for (const i in list) {
                if (type === 'domesticTravel') {
                    let constants = this.form.constants;
                    if (
                        list[i].field !== 'domestic_man_time' &&
                        list[i].field !== 'domestic_days'
                    ) {
                        tabTotal += list[i].input.reduce(
                            (a, b) =>
                                parseFloat(a || '0') + parseFloat(b || '0'),
                            0
                        );
                    }
                    if (list[i].field === 'domestic_man_time') {
                        let times = list[i].input.reduce(
                            (a, b) =>
                                parseFloat(a || '0') + parseFloat(b || '0'),
                            0
                        );
                        tabTotal +=
                            times *
                            parseFloat(constants.domestic_transportation || 0);
                    }
                    if (list[i].field === 'domestic_days') {
                        let days = list[i].input.reduce(
                            (a, b) =>
                                parseFloat(a || '0') + parseFloat(b || '0'),
                            0
                        );
                        tabTotal +=
                            days *
                            (parseFloat(constants.domestic_accommodation || 0) +
                                parseFloat(constants.domestic_meals || 0));
                    }
                } else if (type === 'foreignTravel') {
                    let constants = this.form.constants;
                    if (
                        list[i].field !== 'foreign_man_time' &&
                        list[i].field !== 'foreign_days'
                    ) {
                        tabTotal += list[i].input.reduce(
                            (a, b) =>
                                parseFloat(a || '0') + parseFloat(b || '0'),
                            0
                        );
                    }
                    if (list[i].field === 'foreign_man_time') {
                        let times = list[i].input.reduce(
                            (a, b) =>
                                parseFloat(a || '0') + parseFloat(b || '0'),
                            0
                        );
                        tabTotal +=
                            times *
                            (parseFloat(constants.foreign_transportation || 0) +
                                parseFloat(constants.visa || 0));
                    }
                    if (list[i].field === 'foreign_days') {
                        let days = list[i].input.reduce(
                            (a, b) =>
                                parseFloat(a || '0') + parseFloat(b || '0'),
                            0
                        );
                        tabTotal +=
                            days *
                            (parseFloat(constants.foreign_accommodation || 0) +
                                parseFloat(constants.foreign_meals || 0));
                    }
                } else if (type === 'labourCost') {
                    tabTotal += list[i].values.reduce(
                        (a, b) => parseFloat(a || '0') + parseFloat(b || '0'),
                        0
                    );
                } else {
                    tabTotal += list[i].input.reduce(
                        (a, b) => parseFloat(a || '0') + parseFloat(b || '0'),
                        0
                    );
                }
            }
            if (type === 'labourCost') {
                let inputs = this.form.historyManPowerInput;
                if (inputs.length === 2 && inputs[1].hasOwnProperty('input')) {
                    let historyManPowerInput = this.form.historyManPowerInput;
                    tabTotal += historyManPowerInput[1].input.reduce(
                        (a, b) => parseFloat(a || '0') + parseFloat(b || '0'),
                        0
                    );
                    return tabTotal + addtionCost;
                }
            }
            return tabTotal;
        },
        sumPercentage() {
            //收入拆分总比例
            let list = this.form.incomeDistribution;
            let total = 0;
            for (const i in list) {
                total += parseFloat(list[i].percentage || 0);
            }
            return total;
        },
        addManPowerRow() {
            let total = this.form.manPowerInput.pop();
            let arr;
            (arr = []).length = this.estLabourMonth().length;
            arr.fill(0);
            let j = {
                isTotal: false,
                implement_department: '',
                implement_department_id:'',
                labour_type: '0',
                role: '',
                module: '',
                sub_module: '',
                input: arr,
                historyCost: arr,
                historyInput: arr,
                k: 1,
            };
            this.form.manPowerInput.push(j);
            if (total) {
                this.form.manPowerInput.push(total);
            } else {
                let item = {
                    text: '总计',
                    total: true,
                    input: [],
                    isTotal: true,
                };
                this.form.manPowerInput.push(item);
            }
        },
        addOutSourcingManPowerRow() {
            let total = this.form.manPowerOutSourcingInput.pop();
            let rowCount = this.form.manPowerOutSourcingInput.length;
            let arr;
            (arr = []).length = this.form.allMonths.length;
            arr.fill(0);
            let j = {
                implement_department: '',
                implement_department_id: '',
                labour_type: '1',
                role: '',
                module: '',
                sub_module: '',
                input: arr,
                avg_salary: 0,
                isTotal: false,
            };
            this.form.manPowerOutSourcingInput.push(j);
            if (total) {
                this.form.manPowerOutSourcingInput.push(total);
            } else {
                let item = {
                    text: '总计',
                    total: true,
                    input: arr,
                    isTotal: true,
                };
                this.form.manPowerOutSourcingInput.push(item);
            }
            console.log(this.form.business_department_id);
        },
        addIncomeDistributionRow(bu) {
            let rowCount = this.form.incomeDistribution[0];
            if(rowCount && bu){
                rowCount.implement_department = bu || '';
                rowCount.implement_department_id = '';
                rowCount.type = bu ? bu : '';
                rowCount.percentage = bu ? 25 : 0 ;
                this.form.incomeDistribution[0] = rowCount ;
            }else{
                let j = {
                    id: this.form.incomeDistribution.length + 1,
                    implement_department: bu || '',
                    implement_department_id: '',
                    type: bu ? 'bu' : '',
                    percentage: bu ? 25 : 0,
                    income: 0,
                    manager: '',
                    manager_id: '',
                    abbr_name: '',
                    cost: 0,
                    sub_project_name: '',
                    sub_project_id: '',
                    history_cost: '0',
                    canDelete: true,
                };
                this.form.incomeDistribution.push(j);
            }
        },
        addStagePlanRow() {
            let total = this.form.stagePlans.pop();
            let rowCount = this.form.stagePlans.length;
            let j = {
                id: rowCount + 1,
                milestone: '',
                deliver_date: '',
                is_check_node: '',
                amount: '',
                terms: '',
                stage_name: '',
                stage_start: '',
                stage_end: '',
                est_input_man_month: '',
                est_input_cost: '',
                total: false,
            };
            this.form.stagePlans.push(j);
            if (total) {
                this.form.stagePlans.push(total);
            } else {
                let item = {
                    id: 'total',
                    text: '总计',
                    total: true,
                    amount: '',
                    est_input_man_month: '',
                    est_input_cost: '',
                };
                this.form.stagePlans.push(item);
            }
        },
        sumManMonth(row) {
            const sum = row.input.reduce(
                (a, b) => parseFloat(a || '0') + parseFloat(b || '0'),
                0
            );
            return sum;
        },
        sumManMonthPerM(ind, type) {
            let list =
                type == 0
                    ? this.form.manPowerInput
                    : this.form.manPowerOutSourcingInput;
            var sum = [];
            //保存结果的数组
            var result = [];
            list.map((item) => {
                if (!item.total) {
                    sum.push(item.input);
                }
            });
            for (var key in sum) {
                //遍历数组的每一项
                $.each(sum[key], function (index, val) {
                    if (result[index] == null || result[index] == '') {
                        result[index] = 0;
                    }
                    result[index] += parseFloat(val || 0);
                });
            }
            return result[ind];
        },
        sumStageTotal(name) {
            let total = 0;
            let list = this.form.stagePlans;
            list.map((item) => {
                if (!item.total) {
                    total += parseFloat(item[name] || 0);
                }
            });
            return total;
        },
        preProjectNameAsync(queryString , cb){
            let preProjectNamelist = [{}]
            const url = `${process.env.VUE_APP_PROJECT_REQUEST_HOST}/api/base/project/query`;
            if (queryString != undefined && queryString.length > 2) {
                this.$axios
                    .get(url, { params: { name: queryString } })
                    .then((response) => {
                        preProjectNamelist = response.data.data;
                        cb(preProjectNamelist)
                        console.log(preProjectNamelist)
                    });
            }
        },
        querySearchAsync(queryString, cb) {
            let employees = [{}];
            this.$axios
                .get(
                    `${this.BACKEND_API}/api/base/employee/?format=json&search=${queryString}`
                )
                .then((response) => {
                    for (let i of response.data.data) {
                        i.value = i.name;
                    }
                    employees = response.data.data;
                    cb(employees);
                })
                .catch((error) => {
                    console.log(error);
                });
        },
        createStateFilter(queryString) {
            return (state) => {
                return (
                    state.name
                        .toLowerCase()
                        .indexOf(queryString.toLowerCase()) === 0 ||
                    state.pinyin
                        .toLowerCase()
                        .indexOf(queryString.toLowerCase()) === 0
                );
            };
        },
        loadProductList() {
            this.$axios
                .get(
                    `${process.env.VUE_APP_PROJECT_REQUEST_HOST}/api/base/tech_center`
                )
                .then((res) => {
                    this.productList = res.data.data.filter((item) => {
                        return item.available === true;
                    });
                })
                .catch((err) => {
                    console.log(err);
                });
        },
        loadCustomers() {
            this.$axios
                .get(
                    `${this.BACKEND_API}/api/base/customer/?format=json`
                ).then(
                    (response) =>
                        (this.customers = response.data.map((x) => {
                            x.pinyin = pinyin(x.full_name, {
                                style: pinyin.STYLE_NORMAL,
                            }).join('');
                            x.abbr_name = x.abbr_name || '';
                            x.value = x.full_name;
                            return x;
                        }))
                );
        },
        loadSoftwarePlatforms() {
            this.$axios
                .get(`${this.BACKEND_API}/api/base/sw_platform/?format=json`)
                .then((response) => (this.software_platforms = response.data));
        },
        loadHardwarePlatforms() {
            this.$axios
                .get(`${this.BACKEND_API}/api/base/hw_platform/?format=json`)
                .then((response) => (this.hardware_platforms = response.data));
        },
        loadRoles() {
            this.$axios
                .get(`${this.BACKEND_API}/api/base/role/?format=json`)
                .then((response) => (this.roles = response.data.data));
        },
        loadEmployees() {
            this.$axios
                .get(`${this.BACKEND_API}/api/base/employee/?format=json`)
                .then((response) => (this.employees = response.data.data));
        },
        loadCorporations() {
            this.$axios
                .get(`${this.BACKEND_API}/api/base/corporation/?format=json`)
                .then(
                    (response) =>
                        (this.corporations = response.data.data.map((x) => {
                            x.pinyin = pinyin(x.name, {
                                style: pinyin.STYLE_NORMAL,
                            }).join('');
                            x.value = x.name;
                            return x;
                        }))
                );
        },
        loadDepartments() {
            this.$axios
                .get(
                   `${this.BACKEND_API}/api/base/department/?format=json&level=2`
                )
                .then(
                    (response) =>
                        (this.departments = response.data.data.map((x) => {
                            x.pinyin = pinyin(x.name, {
                                style: pinyin.STYLE_NORMAL,
                            }).join('');
                            x.value = x.name;
                            return x;
                        }))
                );
        },
        calculateSummary(row) {
            if (!this.isUndefined(row.input)) {
                let sum = row.input.reduce((a, b) => {
                    let num = parseFloat(this.num45Filter(a).replace(/,/g, ''));
                    let num2 = parseFloat(
                        this.num45Filter(b).replace(/,/g, '')
                    );
                    return (num || 0) + (num2 || 0);
                }, 0);
                return sum;
            }
        },
        calculateManPowerSummary(row) {
            if (!this.isUndefined(row.values)) {
                let sum = row.values.reduce((a, b) => {
                    let num = parseFloat(this.num45Filter(a).replace(/,/g, ''));
                    let num2 = parseFloat(
                        this.num45Filter(b).replace(/,/g, '')
                    );
                    return (num || 0) + (num2 || 0);
                }, 0);
                return sum;
            }
        },
        calculateDepreciation() {
            let depreciation = this.form.depreciation;

            let manmouthList = []; //人月
            let list = this.form.manPowerInput;
            var sum = [];
            //保存结果的数组
            var result = [];
            list.map((item) => {
                if (!item.total) {
                    sum.push(item.input);
                }
            });
            for (var key in sum) {
                //遍历数组的每一项
                $.each(sum[key], function (index, val) {
                    if (result[index] == null || result[index] == '') {
                        result[index] = 0;
                    }
                    result[index] += parseFloat(val || 0);
                });
            }
            if (this.form.manPowerInput.length) {
                this.form.manPowerInput[
                    this.form.manPowerInput.length - 1
                ].input = result;
                manmouthList = result;
            }
            let historyManPowerInput = this.form.historyManPowerInput[0].input;
            result = historyManPowerInput.concat(result);
            console.log('result', result);
            let assets = [];
            let immaterial = [];

            this.form.assets.map((item2) => {
                this.form.allMonths.map((v, i) => {
                    assets[i] =
                        parseFloat(item2.input[i] || 0) +
                        parseFloat(assets[i] || 0);
                });
            });
            this.form.immaterial.map((item3) => {
                this.form.allMonths.map((v, i) => {
                    immaterial[i] =
                        parseFloat(item3.input[i] || 0) +
                        parseFloat(immaterial[i] || 0);
                });
            });

            // console.log(this.form.immaterial)
            this.form.allMonths.map((v, i) => {
                depreciation.map((item4, i4) => {
                    if (item4.field === 'rent') {
                        item4.input[i] =
                            parseFloat(
                                this.form.constants.depreciation_rent || 0
                            ) * parseFloat(result[i] || 0);
                    }
                    if (item4.field === 'computer') {
                        item4.input[i] =
                            (parseFloat(
                                this.form.constants.depreciation_computer || 0
                            ) *
                                parseFloat(result[i] || 0)) /
                            36;
                    }
                    if (item4.field === 'renovation') {
                        item4.input[i] =
                            parseFloat(
                                this.form.constants.depreciation_renovation || 0
                            ) * parseFloat(result[i] || 0);
                    }
                    if (item4.field === 'house') {
                        item4.input[i] =
                            parseFloat(
                                this.form.constants.depreciation_house || 0
                            ) * parseFloat(result[i] || 0);
                    }
                    // 折旧与摊销 > 固定资产折旧 > 计算
                    if (item4.field === 'fixed_assets') {
                        let result;
                        if (i === 0) {
                            result = parseFloat(assets[i] / 36 || 0);
                        } else {
                            result =
                                parseFloat(assets[i] / 36 || 0) +
                                parseFloat(item4.input[i - 1] || 0);
                        }
                        console.log(i, assets[i], result);
                        item4.input[i] = result;
                    }
                    if (item4.field === 'intangible_assets') {
                        if (i === 0) {
                            item4.input[i] = parseFloat(
                                immaterial[i] / 24 || 0
                            );
                        } else {
                            item4.input[i] =
                                parseFloat(immaterial[i] / 24 || 0) +
                                parseFloat(item4.input[i - 1] || 0);
                        }
                    }
                    this.$set(this.form.depreciation, i4, depreciation[i4]);
                });
            });
            this.calculateTotalCost();
            this.profit = this.estIncomeRaw * this.form.currency - this.estCost;
            if (this.estCost) {
                this.profit_rate =
                    ((this.estIncomeRaw * this.form.currency - this.estCost) *
                        100) /
                    (this.estIncomeRaw * this.form.currency);
            }
            if (this.totalManMonth && this.totalManMonth !== 0) {
                this.avgCostRMB = this.estCost / this.totalManMonth;
            }
        },
        calculateTotalIncome() {
            let form = this.form;
            let totalIncome = 0;
            let totalIncomeRaw = 0;
            for (const key in form) {
                if (Array.isArray(form[key])) {
                    for (const i in form[key]) {
                        if (
                            form[key][i].hasOwnProperty('input') &&
                            form[key][i].hasOwnProperty('input_type') &&
                            form[key][i].input_type === 0
                        ) {
                            totalIncome += form[key][i].input.reduce(
                                (a, b) =>
                                    parseFloat(a || '0') + parseFloat(b || '0'),
                                0
                            );
                        }
                        if (
                            form[key][i].hasOwnProperty('input') &&
                            form[key][i].hasOwnProperty('input_type') &&
                            form[key][i].input_type === 1
                        ) {
                            totalIncomeRaw += form[key][i].input.reduce(
                                (a, b) =>
                                    parseFloat(a || '0') + parseFloat(b || '0'),
                                0
                            );
                        }
                    }
                }
            }
            this.estIncome = totalIncome;
            this.estIncomeRaw = totalIncomeRaw;
        },
        calculateTotalCost() {
            console.log('计算总成本');
            let form = this.form;
            let totalCost = 0;
            let totalOutsourcing = 0;
            let totalPurchase = 0;
            let totalProduction = 0;
            for (const key in form) {
                if (
                    Array.isArray(form[key]) &&
                    key !== 'assets' &&
                    key !== 'immaterial'
                ) {
                    for (const i in form[key]) {
                        if (
                            form[key][i].hasOwnProperty('input') &&
                            form[key][i].hasOwnProperty('input_type') &&
                            form[key][i].input_type === 4
                        ) {
                            let cost = form[key][i].input.reduce(
                                (a, b) =>
                                    parseFloat(a || '0') + parseFloat(b || '0'),
                                0
                            );
                            console.log(
                                `calc: k: ${key}, index: ${i}, 成本: ${cost}`
                            );
                            totalCost += cost;
                            // 采购成本
                            if (key === 'purchaseCost') {
                                totalPurchase += cost;
                            }
                            if (key === 'productionCost') {
                                totalProduction += cost;
                            }
                            this.form.purchaseCostNum =
                                totalPurchase + totalProduction;
                            // 外包成本
                            if (key === 'outsourcingProjectCost') {
                                totalOutsourcing += cost;
                                this.form.outsourcingProjectCostNum = totalOutsourcing;
                            }
                        }
                        let constants = this.form.constants;
                        if (form[key][i].field === 'domestic_man_time') {
                            let times = form[key][i].input.reduce(
                                (a, b) =>
                                    parseFloat(a || '0') + parseFloat(b || '0'),
                                0
                            );
                            let cost =
                                times *
                                parseFloat(
                                    constants.domestic_transportation || 0
                                );
                            console.log(
                                `calc: k: ${key}, index: ${i}, 成本: ${cost}`
                            );
                            totalCost += cost;
                        }
                        if (form[key][i].field === 'domestic_days') {
                            let days = form[key][i].input.reduce(
                                (a, b) =>
                                    parseFloat(a || '0') + parseFloat(b || '0'),
                                0
                            );
                            let cost =
                                days *
                                (parseFloat(
                                    constants.domestic_accommodation || 0
                                ) +
                                    parseFloat(constants.domestic_meals || 0));
                            // console.log(
                            //     `calc: k: ${key}, index: ${i}, 成本: ${cost}`
                            // );
                            totalCost += cost;
                        }
                        if (form[key][i].field === 'foreign_man_time') {
                            let times = form[key][i].input.reduce(
                                (a, b) =>
                                    parseFloat(a || '0') + parseFloat(b || '0'),
                                0
                            );
                            let cost =
                                times *
                                (parseFloat(
                                    constants.foreign_transportation || 0
                                ) +
                                    parseFloat(constants.visa || 0));
                            // console.log(
                            //     `calc: k: ${key}, index: ${i}, 成本: ${cost}`
                            // );
                            totalCost += cost;
                        }
                        if (form[key][i].field === 'foreign_days') {
                            let days = form[key][i].input.reduce(
                                (a, b) =>
                                    parseFloat(a || '0') + parseFloat(b || '0'),
                                0
                            );
                            let cost =
                                days *
                                (parseFloat(
                                    constants.foreign_accommodation || 0
                                ) +
                                    parseFloat(constants.foreign_meals || 0));
                            // console.log(
                            //     `calc: k: ${key}, index: ${i}, 成本: ${cost}`
                            // );
                            totalCost += cost;
                        }
                    }
                }
            }
            console.log('采购成本:', this.form.purchaseCostNum);
            console.log('人力成本:', this.form.outsourcingProjectCostNum);
            // 计算公司人力成本
            let toalLabourCost = 0;
            this.form.labourCost.forEach((row) => {
                let cost = row.values.reduce(
                    (a, b) => parseFloat(a || '0') + parseFloat(b || '0'),
                    0
                );
                toalLabourCost += cost;
                totalCost += cost;
            });
            console.log(`calc: 公司人力合计: ${toalLabourCost}`);
            // 计算其他人力成本
            let totalLabourOtherCost = form.labourOtherCost[0].input.reduce(
                (a, b) => parseFloat(a || '0') + parseFloat(b || '0'),
                0
            );
            totalCost += totalLabourOtherCost;
            console.log(
                `calc: 公司人力其它人力, 成本: ${totalLabourOtherCost}`
            );

            this.estCost = totalCost + parseFloat(this.form.pre_cost || 0) ;
        },
        calculateLabourCost() {
            let total_income_list = [];
            let out_sourcing_list = [];
            this.form.projectIncome.map((item1) => {
                if (item1.input_type == 0) {
                    item1.input.map((v, i) => {
                        total_income_list[i] =
                            parseFloat(v || 0) +
                            parseFloat(total_income_list[i] || 0);
                    });
                }
            });
            this.form.outsourcingProjectCost.map((item2) => {
                item2.input.map((v, i) => {
                    out_sourcing_list[i] =
                        parseFloat(v || 0) +
                        parseFloat(out_sourcing_list[i] || 0);
                });
            });

            let data = {
                labour_input: this.form.manPowerInput,
                total_income: total_income_list.map((income) => {
                    return income * this.form.currency;
                }),
                out_sourcing_cost: out_sourcing_list,
                housing_fund: this.form.housing_fund_rate,
                history_man_power: this.form.historyManPowerInput,
            };
            this.$axios
                .post(`${this.BACKEND_API}/api/base/labour_cost`, data)
                .then((response) => {
                    if(response.data.code === 400){
                        this.message(`无法计算人力成本，工数预测实施部门${response.data.msg}`,"warning")
                        return false;
                    }
                    this.form.labourCost = response.data.data;
                    this.form.group_salary_cost =
                        response.data.group_salary_cost;
                })
                .then(() => {
                    this.calculateTotalCost();
                    this.profit =
                        this.estIncomeRaw * this.form.currency - this.estCost;
                    if (this.estCost) {
                        this.profit_rate =
                            ((this.estIncomeRaw * this.form.currency -
                                this.estCost) *
                                100) /
                            (this.estIncomeRaw * this.form.currency);
                    }
                    if (this.totalManMonth && this.totalManMonth !== 0) {
                        this.avgCostRMB = this.estCost / this.totalManMonth;
                    }
                });
        },
        calculateOutSourcingCost() {
            // clear dev project cost
            this.form.outsourcingProjectCost[0].input = new Array(
                this.form.allMonths.length
            ).fill(0);
            // clear pm project cost
            this.form.outsourcingProjectCost[1].input = new Array(
                this.form.allMonths.length
            ).fill(0);
            // clear val project cost
            this.form.outsourcingProjectCost[2].input = new Array(
                this.form.allMonths.length
            ).fill(0);
            let manPowerOutList = this.form.manPowerOutSourcingInput;
            let sumDevManMonth = new Array(this.form.allMonths.length).fill(0);
            let sumTestManMonth = new Array(this.form.allMonths.length).fill(0);
            let sumPMManMonth = new Array(this.form.allMonths.length).fill(0);
            manPowerOutList.map((item) => {
                if (!item.total) {
                    if (item.role === '研发') {
                        item.input.map((manMonth, monthIndex) => {
                            let sumCost =
                                parseFloat(manMonth || 0) *
                                parseFloat(item.avg_salary);
                            sumDevManMonth[monthIndex] += sumCost;
                        });
                    }
                    if (item.role === '项目') {
                        item.input.map((manMonth, monthIndex) => {
                            let sumCost =
                                parseFloat(manMonth || '0') *
                                parseFloat(item.avg_salary);
                            sumPMManMonth[monthIndex] += sumCost;
                        });
                    }
                    if (item.role === '测试') {
                        item.input.map((manMonth, monthIndex) => {
                            let sumCost =
                                parseFloat(manMonth || '0') *
                                parseFloat(item.avg_salary);
                            sumTestManMonth[monthIndex] += sumCost;
                        });
                    }
                }
            });
            this.form.outsourcingProjectCost[0].input = sumDevManMonth;
            this.form.outsourcingProjectCost[1].input = sumPMManMonth;
            this.form.outsourcingProjectCost[2].input = sumTestManMonth;
        },
        queryArchivedProjects(userId) {
            this.$axios
                // .get(`${this.BACKEND_API}/api/base/project`, {
                .get(`${this.BACKEND_API}/api/base/oa_project`, {
                    params: {
                        status: '03',
                        user_id: userId,
                        form_status: 1,
                    },
                })
                .then((response) => {
                    this.archivedProjects = response.data.data;
                });
        },
        handleSelectionChange(val){
            this.fileList = val
        },
        handleDownloadAttachmentAll(){
            this.fileList.forEach(item=>{
                this.$axios.get(
                    `${this.BACKEND_API}/api/base/workflow/download_attachment?project_name=${this.form.form_id}&request_file=${item.fileName}`
                    ,{responseType:'blob'}
                ).then( res =>{
                    const blob = new Blob([res.data]);
                    let url = window.URL.createObjectURL(blob);
                    let a = document.createElement('a');
                    a.href = url;
                    a.download = item.fileName;
                    a.click();
                }).catch(err=>{
                    console.log("下载失败")
                })
            })
        },
        handleDownloadAttachment(index, row) {
            window.open(row.path);
        },
        handleDeleteAttachment(index, row) {
            this.form.file_list.splice(index, 1);
        },
        handleSpecialApprovalDeleteAttachment(index, row) {
            this.form.special_approval_list.splice(index, 1);
        },
        getUserInfo() {
            return new Promise((resolve, reject) => {
                this.$axios
                    .get(
                        `${process.env.VUE_APP_PROJECT_REQUEST_HOST}/api/base/employee/`,
                        {
                            params: {
                                ldap: getName(),
                            },
                        }
                    )
                    .then((response) => {
                        this.userInfo = response.data.data[0];
                        resolve(response);
                    })
                    .catch((err) => {
                        reject(err);
                    });
            });
        },
        sumTotalManMonth(inputs) {
            let filterInputs = inputs
                .filter((item) => item.isTotal === false)
                .map(function (v) {
                    return v.input;
                });
            let sum = filterInputs
                .reduce(function (a, b) {
                    return a.concat(b);
                }, [])
                .reduce(function (a, b) {
                    return parseFloat(a || '0') + parseFloat(b || '0');
                }, 0);
            return sum;
        },
    },
};
</script>

<style lang="scss" scoped>
/deep/ .el-input.is-readonly {
    background-color: #f5f7fa;
    border-color: #dfe4ed;
    color: #ff6363;
    cursor: not-allowed;
}

.table-form {
    margin-bottom: 0;
}

.table-form /deep/ .el-form-item__error {
    position: relative;
}

/deep/ .el-checkbox__input.is-disabled.is-checked .el-checkbox__inner {
    background-color: black;
    border-color: rgb(233, 233, 240);
}

.form {
    margin-bottom: 180px;
}

/deep/ .el-input.is-disabled .el-input__inner {
    color: black;
}

/deep/ .el-textarea.is-disabled .el-textarea__inner {
    color: black;
}
/deep/ .el-table td.cell-green {
    background-color: #13ce66 !important;
    color: #fff;
}
.inline-input {
    width: 100%;
}

.request-submit {
    //width: 1140px;
    position: fixed;
    z-index: 998;
    padding: 15px 25px 15px 200px;
    bottom: 24px;
    height: 120px;
    border-top: 1px solid #dbe3e4;
    background-color: #fff;
    box-shadow: 0 -4px 4px -2px #e4e9f8;
    left: 54px;
    right: 0;
}

.el-select .el-input {
    width: 110px;
}

.input-with-select .el-input-group__prepend {
    background-color: #fff;
}

.label-item {
    margin-bottom: 8px;
    display: block;
}

.label-item:first-child {
    margin-bottom: 8px;
    display: block;
}

.label-item .label {
    width: 160px;
    text-align: right;
    display: inline-block;
    margin-right: 10px;
    color: #666;
}

.label-item .detail {
    display: inline-block;
}

.operations {
    display: inline-block;
    text-align: right;
    width: 8%;
}

.input-platform {
    margin-right: 15px;
}

.cost-about {
    display: inline-block;
    width: 31%;
    vertical-align: top;
    border-left: 1px solid #ddd;
    padding-right: 10px;
    box-sizing: border-box;
}

.cost-about:last-child {
    display: inline-block;
    width: 28%;
    vertical-align: top;
    border-left: 1px solid #ddd;
    padding-right: 10px;
    box-sizing: border-box;
}

.cost-about:first-child {
    display: inline-block;
    width: 33%;
    border: none;
    vertical-align: top;
    padding-right: 10px;
    box-sizing: border-box;
}

.cost-about .cost-price .price {
    font-size: 18px;
    font-weight: 700;
    color: #ed711f;
}

.project-request-container {
    min-width: 1140px;
    margin: 45px;
}

h3.project-title {
    color: rgb(31, 47, 61);
    font-weight: 400;
    font-size: 22px;
}

.btn-add {
    margin-bottom: 15px;
}

.el-row {
    margin-bottom: 20px;
}

.el-col {
    border-radius: 4px;
}

.grid-content {
    border-radius: 4px;
    min-height: 36px;
}

.row-bg {
    padding: 10px 0;
}

.input-label {
    display: inline-block;
    width: 130px;
}
.transitions {
    position: absolute;
    top: -25px;
    left: 0;
    color: #ff9900;
    font-weight: bold;
    font-size: 12px;
}
.transitions2 {
    position: absolute;
    top: 30px;
    left: 0;
    color: #ff9900;
    font-weight: bold;
    font-size: 12px;
}
.tip {
    float: right;
    line-height: 36px;
    font-size: 14px;
    color: #909399;
}
</style>
